Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

minimal-sdl2 - Could not retrieve any SDL2 window info on Ubuntu 19.10 #53

Closed
rofrol opened this issue Jan 12, 2020 · 28 comments · Fixed by #109
Closed

minimal-sdl2 - Could not retrieve any SDL2 window info on Ubuntu 19.10 #53

rofrol opened this issue Jan 12, 2020 · 28 comments · Fixed by #109
Labels
help wanted Extra attention is needed upstream bug Bug appears to originate in an upstream dependency

Comments

@rofrol
Copy link

rofrol commented Jan 12, 2020

$ cargo run --example minimal-sdl2 --features="minimal-sdl2"
    Finished dev [unoptimized + debuginfo] target(s) in 0.06s
     Running `target/debug/examples/minimal-sdl2`
thread 'main' panicked at 'Could not retrieve any SDL2 window info, and Osspial wrote the trait to be infallible despite that clearly not always being the case, so now you got this panic. https://github.com/rust-windowing/raw-window-handle/issues/new', /home/roman/.cargo/registry/src/github.com-1ecc6299db9ec823/beryllium-0.1.2/src/window.rs:152:7
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.

Dep installed with:

sudo apt install libsdl2-dev

Should I install something else? I have found this links:

@parasyte
Copy link
Owner

This panic message is from Beryllium (a safe wrapper for libsdl2), which depends on Fermium (an unsafe binding for libsdl2). This happens when fermium::SDL_GetWindowWMInfo() returns false.

Have you installed libsdl2?

@rofrol
Copy link
Author

rofrol commented Jan 13, 2020

$ apt policy libsdl2-dev
libsdl2-dev:
  Installed: 2.0.10+dfsg1-1ubuntu1
  Candidate: 2.0.10+dfsg1-1ubuntu1
  Version table:
 *** 2.0.10+dfsg1-1ubuntu1 500
        500 http://pl.archive.ubuntu.com/ubuntu eoan/universe amd64 Packages
        100 /var/lib/dpkg/status

Do I need to install sth else?

@parasyte
Copy link
Owner

The fermium README says it uses libsdl 2.0.8 by default, but I don't know if it's a linking problem.

Try the fermium example: https://github.com/Lokathor/fermium/tree/master/examples

E.g.:

$ git clone https://github.com/Lokathor/fermium.git
$ cd fermium
$ cargo run --example window

@rofrol
Copy link
Author

rofrol commented Jan 13, 2020

Seems to work. I see window with black background.

image

@parasyte
Copy link
Owner

Also try on the v1.3.0 tag.

And if that still works fine, then move on to trying the beryllium example (tag v1.2.0).

If all of that still works, then I'm at a complete loss, because the pixels sdl2 example doesn't do anything special, AFAICT.

@rofrol
Copy link
Author

rofrol commented Jan 13, 2020

v1.3.0 of what?

@rofrol
Copy link
Author

rofrol commented Jan 13, 2020

oh, beryllium v0.1.3?

@parasyte
Copy link
Owner

Our Cargo.lock file specifies fermium 0.1.3:

"fermium 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
Which corresponds to tag v1.3.0.

And beryllium 1.2.0 which corresponds to tag v1.2.0. Two different crates for interfacing with sdl2.

@rofrol
Copy link
Author

rofrol commented Jan 13, 2020

fermium seems to work:

~/personal_projects/rust/vendor/fermium (master)$ git co v0.1.3
Note: switching to 'v0.1.3'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by switching back to a branch.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -c with the switch command. Example:

  git switch -c <new-branch-name>

Or undo this operation with:

  git switch -

Turn off this advice by setting config variable advice.detachedHead to false

HEAD is now at 0debe20 (cargo-release) version 0.1.3
~/personal_projects/rust/vendor/fermium ((v0.1.3))$ cargo run --example window
    Updating crates.io index
   Compiling fermium v0.1.3 (/home/roman/personal_projects/rust/vendor/fermium)
   Compiling cfg-if v0.1.10
    Finished dev [unoptimized + debuginfo] target(s) in 3.29s
     Running `target/debug/examples/window`
Quit after 5870 milliseconds.
~/personal_projects/rust/vendor/fermium ((v0.1.3))$ git co v0.1.2
Previous HEAD position was 0debe20 (cargo-release) version 0.1.3
HEAD is now at 0db5649 (cargo-release) version 0.1.2
~/personal_projects/rust/vendor/fermium ((v0.1.2))$ cargo run --example window
   Compiling fermium v0.1.2 (/home/roman/personal_projects/rust/vendor/fermium)
    Finished dev [unoptimized + debuginfo] target(s) in 1.57s
     Running `target/debug/examples/window`
Quit after 2394 milliseconds.

@rofrol
Copy link
Author

rofrol commented Jan 13, 2020

beryllium also seems to work:

~/personal_projects/rust/vendor/beryllium (master)$ cargo run --example basic_window
   Compiling beryllium v0.2.0-alpha.5 (/home/roman/personal_projects/rust/vendor/beryllium)
    Finished dev [unoptimized + debuginfo] target(s) in 0.33s
     Running `target/debug/examples/basic_window`
~/personal_projects/rust/vendor/beryllium (master)$ git co v0.1.3
Note: switching to 'v0.1.3'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by switching back to a branch.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -c with the switch command. Example:

  git switch -c <new-branch-name>

Or undo this operation with:

  git switch -

Turn off this advice by setting config variable advice.detachedHead to false

HEAD is now at cf59dd5 (cargo-release) version 0.1.3
~/personal_projects/rust/vendor/beryllium ((v0.1.3))$ cargo run --example blank_window
    Updating crates.io index
   Compiling beryllium v0.1.3 (/home/roman/personal_projects/rust/vendor/beryllium)
    Finished dev [unoptimized + debuginfo] target(s) in 1.47s
     Running `target/debug/examples/blank_window`
Quitting the program after 2503 milliseconds.
~/personal_projects/rust/vendor/beryllium ((v0.1.3))$ git co v0.1.2
Previous HEAD position was cf59dd5 (cargo-release) version 0.1.3
HEAD is now at feb6f23 (cargo-release) version 0.1.2
~/personal_projects/rust/vendor/beryllium ((v0.1.2))$ cargo run --example blank_window
   Compiling beryllium v0.1.2 (/home/roman/personal_projects/rust/vendor/beryllium)
    Finished dev [unoptimized + debuginfo] target(s) in 0.45s
     Running `target/debug/examples/blank_window`
Quitting the program after 2007 milliseconds.

@parasyte
Copy link
Owner

parasyte commented Jan 13, 2020

Another question, do you know if it's using Wayland or X11? I've seen weird problems with Wayland before (#29).

You can force sdl2 to use X11 with an environment variable:

$ SDL_VIDEODRIVER=x11 cargo run --example minimal-sdl2 --features="minimal-sdl2"

Other values are documented: https://wiki.libsdl.org/FAQUsingSDL#How_do_I_choose_a_specific_video_driver.3F

@rofrol
Copy link
Author

rofrol commented Jan 13, 2020

~/personal_projects/rust/vendor/parasyte/pixels (master)$ SDL_VIDEODRIVER=x11 cargo run --example minimal-sdl2 --features="minimal-sdl2"
    Finished dev [unoptimized + debuginfo] target(s) in 0.15s
     Running `target/debug/examples/minimal-sdl2`
thread 'main' panicked at 'Could not retrieve any SDL2 window info, and Osspial wrote the trait to be infallible despite that clearly not always being the case, so now you got this panic. h
ttps://github.com/rust-windowing/raw-window-handle/issues/new', /home/roman/.cargo/registry/src/github.com-1ecc6299db9ec823/beryllium-0.1.2/src/window.rs:152:7
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.

@rofrol
Copy link
Author

rofrol commented Jan 13, 2020

~/personal_projects/rust/vendor/fermium ((v0.1.3))$ cargo run --example window
    Updating crates.io index
   Compiling fermium v0.1.3 (/home/roman/personal_projects/rust/vendor/fermium)
error: failed to run custom build command for `fermium v0.1.3 (/home/roman/personal_projects/rust/vendor/fermium)`

Caused by:
  process didn't exit successfully: `/home/roman/personal_projects/rust/vendor/fermium/target/debug/build/fermium-2b040b905b7694d6/build-script-build` (exit code: 101)
--- stdout
use_bindgen_bin: false
link_dynamic: true
link_static: false
bind_SDL2_2_0_9: false
bind_SDL2_2_0_10: false
cargo:rustc-env=TARGET=x86_64-unknown-linux-gnu
cargo:rustc-env=BIND_PATCH_LEVEL=8

--- stderr
thread 'main' panicked at 'couldn't run `sdl2-config`, please properly install SDL2.: Os { code: 2, kind: NotFound, message: "No such file or directory" }', src/libcore/result.rs:1165:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.

@parasyte
Copy link
Owner

I'm at a loss for now. I'll try to reproduce the issue locally when I get home. Anything you can do to help debug in the meantime will be greatly appreciated.

@rofrol
Copy link
Author

rofrol commented Jan 13, 2020

Oh, this last error was because I have done sudo apt remove libsdl2-dev. After installing again fermium works again.

@rofrol
Copy link
Author

rofrol commented Jan 13, 2020

image

@rofrol
Copy link
Author

rofrol commented Jan 15, 2020

Any news on that?

@parasyte parasyte added the help wanted Extra attention is needed label Jan 20, 2020
@parasyte
Copy link
Owner

@rofrol Could you try the minimal-sdl2 example on the latest master? All dependencies have been updated.

@parasyte parasyte added the question Usability question label Apr 18, 2020
@parasyte
Copy link
Owner

Ping @rofrol Have you been able to try this again since the last update?

@willcrutchley
Copy link

willcrutchley commented Jul 27, 2020

I still have this problem on master. (Manjaro)

@parasyte
Copy link
Owner

I do not know what the problem could be. No way to reproduce this on my end.

Anyone who can reproduce this want to step through the code with a debugger? There should not be many differences between the minimal-sdl2 example and any of the beryllium examples.

@willcrutchley
Copy link

Did a bit of digging, as with OP fermium::SDL_GetWindowWMInfo() returns false.
Calling SDL_GetError after this returns Application not compiled with SDL 2.0 which is strange.
I definitely have sdl2 installed

@parasyte
Copy link
Owner

parasyte commented Jul 27, 2020

This may actually be a bug in beryllium: https://github.com/Lokathor/beryllium/blob/cfdd6a3e14b0b71b5dda1718e1826d815d41e3fd/src/window/raw_window.rs#L49-L50

The default impl for SDL_SysWMinfo is: https://github.com/Lokathor/fermium/blob/fea637f848ea702dd8d6793d0650e6604862e631/src/SDL2-2.0.12-x86_64-unknown-linux-gnu.rs#L6275-L6279

According to the libsdl wiki:

The info structure must be initialized with the SDL version, and is then filled in with information about the given window, as shown in the Code Example.

This suggests that beryllium needs to populate the SDL_SysWMinfo struct with the SDL version at a minimum. The default impl just zeros the struct.

@parasyte parasyte added the upstream bug Bug appears to originate in an upstream dependency label Jul 27, 2020
@parasyte parasyte removed the question Usability question label Jul 27, 2020
@parasyte
Copy link
Owner

@willcrutchley @rofrol If either of you would like to try, please update beryllium to the current HEAD of the master branch:

diff --git a/examples/minimal-sdl2/Cargo.toml b/examples/minimal-sdl2/Cargo.toml
index dae1a53..0d6984b 100644
--- a/examples/minimal-sdl2/Cargo.toml
+++ b/examples/minimal-sdl2/Cargo.toml
@@ -10,7 +10,7 @@ optimize = ["log/release_max_level_warn"]
 default = ["optimize"]

 [dependencies]
-beryllium = { version = "0.3.1", features = ["extern_crate_raw_window_handle"] }
+beryllium = { git = "https://github.com/Lokathor/beryllium.git", rev = "9375bbd2dbc8c35d5f669181a9d525315f20ba40", features = ["extern_crate_raw_window_handle"] }
 env_logger = "0.7.1"
 log = "0.4.8"
 pixels = { path = "../.." }

Lokathor was kind enough to add the SDL version.

@willcrutchley
Copy link

Sorry I missed this. Works great with the new version of beryllium, thank you!
@parasyte

parasyte added a commit that referenced this issue Jul 30, 2020
parasyte added a commit that referenced this issue Jul 30, 2020
@aegroto
Copy link

aegroto commented Aug 1, 2020

This issue seems to be still present on Ubuntu 20, even if all dependencies were installed. May be because of Rust Nightly? I don't know which version of the compiler the OP was using at the time.

@parasyte
Copy link
Owner

parasyte commented Aug 1, 2020

@aegroto I'll have to ask you to please go through all of the troubleshooting steps presented earlier in this thread to determine whether this is the same issue or something else.

FWIW, it is unlikely to be caused by your compiler version. My first suspect would be an environmental issue (e.g. perhaps fermium cannot find your SDL2 library?) And second guess would be an upstream bug in one of the dependencies for SDL2.

pixels itself is entirely agnostic to the windowing system and graphics API. The likelihood of this bug being caused by something within the pixels crate is low. But I will be happy to help you with troubleshooting, and of course if it is our bug, I'll fix it ASAP.

Also, if you find that this is a new problem and that all signs point to the bug being in this repo, please open a new issue so we can track it separately.

@aegroto
Copy link

aegroto commented Aug 1, 2020

Updating the beryllium version to the commit mentioned above solves the issue, stills the example doesn't work out-of-the-box like it's supposed to do.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed upstream bug Bug appears to originate in an upstream dependency
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants