Closed mgunyho closed 1 year ago
Thank you for the report!
I know basically nothing about graphics/OpenGL, but if I understand correctly, the problem is that I'm on X11, which would need GLX, but Slint is trying to use EGL.
It’s odd to me that EGL fails, but you’re totally right: we should try GLX in this case.
I can’t quite reproduce this setup myself, but I can prepare a patch to try a fallback. I’ll let you know when I have something:)
@mgunyho I've made a patch at https://github.com/slint-ui/slint/pull/2165 - it's basically a one-liner (or two-liner :). Could you give it a try?
Thanks for the quick response and patch! However, with 5f1165b93, it still crashes with the same error, though the stack is slightly different:
$ cargo run -p memory
...
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Error { raw_code: Some(12291), raw_os_message: None, kind: OutOfMemory }', internal/backends/winit/renderer/femtovg/glcontext.rs:121:82
...
16: 0x55cfece36dfb - core::result::Result<T,E>::unwrap::h6b4d8991b7c0a9c1
at /rustc/90743e7298aca107ddaa0c202a4d3604e29bfeb6/library/core/src/result.rs:1113:23
17: 0x55cfecec8d35 - i_slint_backend_winit::renderer::femtovg::glcontext::OpenGLContext::new_context::h94eaf85356bb03e9
at .../slint/internal/backends/winit/renderer/femtovg/glcontext.rs:121:26
18: 0x55cfece05343 - <i_slint_backend_winit::renderer::femtovg::FemtoVGRenderer as i_slint_backend_winit::renderer::WinitCompatibleRenderer>::show::h808eaa0ab819455f
at .../slint/internal/backends/winit/renderer/femtovg.rs:58:30
If I do println!("{:?}", config)
just before create_window_surface
, it still shows it's using EGL: Egl(Config { inner: Config { raw: EglConfig(0x561145559990), display: EglDisplay(0x561145520d70) } })
.
I put a println!("hello");
under the #[cfg(all(feature = "x11"), not(target_family="windows"))]
condition which you added, it gets printed.
So looks like glutin is not applying the fallback, even though it should.
Thanks for checking. Ok, that matches also what the egui folks observed then. Tomorrow I'll try to make a patch to use two separated attempts at creating the display instead of asking glutin to do that in one-shot with PreferXThenY
.
Apologies for the delay, it took me longer to re-do the patch. I've updated the PR with a new attempt that tries to deal with the EGL surface creation failing at a later stage and then re-try with GLX.
Looks like on my system it tried to build with winit version 0.28.1 (I guess a leftover in Cargo.lock from some previous build), so I had to apply
diff --git a/internal/backends/winit/renderer/femtovg/glcontext.rs b/internal/backends/winit/renderer/femtovg/glcontext.rs
index 42743f31e..c51676c6e 100644
--- a/internal/backends/winit/renderer/femtovg/glcontext.rs
+++ b/internal/backends/winit/renderer/femtovg/glcontext.rs
@@ -61,7 +61,7 @@ pub fn new_context(
if #[cfg(target_os = "macos")] {
let prefs = [glutin::display::DisplayApiPreference::Cgl];
} else if #[cfg(all(feature = "x11", not(target_family = "windows")))] {
- let prefs = [glutin::display::DisplayApiPreference::Egl, glutin::display::DisplayApiPreference::Glx(Box::new(winit::platform::unix::register_xlib_error_hook))];
+ let prefs = [glutin::display::DisplayApiPreference::Egl, glutin::display::DisplayApiPreference::Glx(Box::new(winit::platform::x11::register_xlib_error_hook))];
} else if #[cfg(not(target_family = "windows"))] {
let prefs = [glutin::display::DisplayApiPreference::Egl];
} else {
But other than that, it works! Including the latest version, https://github.com/slint-ui/slint/commit/746fb61495b29277c342018645a7cb14ecab56b4
Excellent, thanks a lot for trying!! Yeah, I noticed the same build issue (and a few more).
I also tried 3441320, and it works as well.
Hi!
I'm trying to run the memory example (or any example really), but I am getting the following error when the program starts:
Full backtrace
``` thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Error { raw_code: Some(12291), raw_os_message: None, kind: OutOfMemory }', internal/backends/winit/renderer/femtovg/glcontext.rs:119:82 stack backtrace: 0: 0x56476254eac0 - std::backtrace_rs::backtrace::libunwind::trace::h1d00f3fcf4cb5ac4 at /rustc/90743e7298aca107ddaa0c202a4d3604e29bfeb6/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5 1: 0x56476254eac0 - std::backtrace_rs::backtrace::trace_unsynchronized::h920a6ff332484ee2 at /rustc/90743e7298aca107ddaa0c202a4d3604e29bfeb6/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5 2: 0x56476254eac0 - std::sys_common::backtrace::_print_fmt::hd7323920c925af6d at /rustc/90743e7298aca107ddaa0c202a4d3604e29bfeb6/library/std/src/sys_common/backtrace.rs:65:5 3: 0x56476254eac0 -This doesn't happen on
v0.3.2
, but onv0.3.3
and later (including master @ f34b1bda2) it does.I tried to run the basic window example from glutin (0.30.3, which is what Slint is using based on
Cargo.lock
), and that worked fine. I found the equivalent call tocreate_window_surface(config, attrs)
, and I checked that theattrs
is the same for both, butconfig
wasGlx(...)
for the glutin example, butEgl(...)
for Slint.I know basically nothing about graphics/OpenGL, but if I understand correctly, the problem is that I'm on X11, which would need GLX, but Slint is trying to use EGL.
I found a similar issue from egui: https://github.com/emilk/egui/issues/2457 and related PR: https://github.com/emilk/egui/pull/2541.
Here's what the glutin example prints:
I'm using Ubuntu 20.04 on an ancient Thinkpad.
As I said, I don't really know what I'm talking about here, so feel free to update the title if it's incorrect or missing something relevant.