emilk / egui

egui: an easy-to-use immediate mode GUI in Rust that runs on both web and native
https://www.egui.rs/
Apache License 2.0
22.43k stars 1.6k forks source link

glow doesn't work on web on Chromium #1087

Closed yusdacra closed 2 years ago

yusdacra commented 2 years ago

Describe the bug

eframe stopped working on web since the egui_glow backend switch.

To Reproduce Steps to reproduce the behavior:

  1. Clone https://github.com/harmony-development/Loqui
  2. Get https://trunkrs.dev/
  3. Run trunk serve in root of repo
  4. Go to 0.0.0.0:8080 in browser and see the errors in console

Expected behavior

It should run fine.

Screenshots

Desktop (please complete the following information):

Additional context

eframe source from Cargo.lock:

[[package]]
name = "eframe"
version = "0.16.0"
source = "git+https://github.com/emilk/egui.git?branch=master#611eaa52e8f669d8972588473413d413507bea32"
Console log ``` WebGL: INVALID_ENUM: getParameter: invalid parameter name, WEBGL_debug_renderer_info not enabled (anonymous) @ index-1c2f9c7ca7558b49.js:831 index-1c2f9c7ca7558b49.js:1635 WebGL2 not available - falling back to WebGL2 index-1c2f9c7ca7558b49.js:1635 egui_glow: detected WebGL prefix at 6:1.0 (OpenGL ES 2.0 Chromium) index-1c2f9c7ca7558b49.js:1635 egui_glow: Shader version: Es100 ("WebGL GLSL ES 1.0 (OpenGL ES GLSL ES 1.0 Chromium)") index-1c2f9c7ca7558b49.js:1635 egui_glow: Shader header: "#version 100\n" index-1c2f9c7ca7558b49.js:701 panicked at 'assertion failed: `(left == right)` left: `1280`, right: `0`: OpenGL error occurred!', /home/patriot/.cargo/git/checkouts/egui-5e4507fa4153be06/611eaa5/egui_glow/src/painter.rs:204:13 Stack: Error at imports.wbg.__wbg_new_693216e109162396 (http://0.0.0.0:8080/index-1c2f9c7ca7558b49.js:707:19) at console_error_panic_hook::Error::new::h13ac39e04fdc84c6 (http://0.0.0.0:8080/index-1c2f9c7ca7558b49_bg.wasm:wasm-function[53906]:0xda50d6) at console_error_panic_hook::hook_impl::h402524c335a55d40 (http://0.0.0.0:8080/index-1c2f9c7ca7558b49_bg.wasm:wasm-function[7466]:0x831380) at console_error_panic_hook::hook::h1c52481292191a7f (http://0.0.0.0:8080/index-1c2f9c7ca7558b49_bg.wasm:wasm-function[60523]:0xdbb4c7) at core::ops::function::Fn::call::h4f82ec833d3421a7 (http://0.0.0.0:8080/index-1c2f9c7ca7558b49_bg.wasm:wasm-function[40307]:0xd2c70e) at std::panicking::rust_panic_with_hook::h606d7c7f7a423b98 (http://0.0.0.0:8080/index-1c2f9c7ca7558b49_bg.wasm:wasm-function[14346]:0xa2470c) at std::panicking::begin_panic_handler::{{closure}}::h9b985a293aac4ce1 (http://0.0.0.0:8080/index-1c2f9c7ca7558b49_bg.wasm:wasm-function[22786]:0xb96e22) at std::sys_common::backtrace::__rust_end_short_backtrace::ha03abef02a8b70fd (http://0.0.0.0:8080/index-1c2f9c7ca7558b49_bg.wasm:wasm-function[53197]:0xda1bef) at rust_begin_unwind (http://0.0.0.0:8080/index-1c2f9c7ca7558b49_bg.wasm:wasm-function[41324]:0xd3ba76) at core::panicking::panic_fmt::h6314b5c91abe7349 (http://0.0.0.0:8080/index-1c2f9c7ca7558b49_bg.wasm:wasm-function[43808]:0xd5beea) imports.wbg.__wbg_error_09919627ac0992f5 @ index-1c2f9c7ca7558b49.js:701 index-1c2f9c7ca7558b49_bg.wasm:0xdc104f Uncaught (in promise) RuntimeError: unreachable at __rust_start_panic (:8080/index-1c2f9c7ca7558b49_bg.wasm) at rust_panic (:8080/index-1c2f9c7ca7558b49_bg.wasm) at std::panicking::rust_panic_with_hook::h606d7c7f7a423b98 (:8080/index-1c2f9c7ca7558b49_bg.wasm) at std::panicking::begin_panic_handler::{{closure}}::h9b985a293aac4ce1 (:8080/index-1c2f9c7ca7558b49_bg.wasm) at std::sys_common::backtrace::__rust_end_short_backtrace::ha03abef02a8b70fd (:8080/index-1c2f9c7ca7558b49_bg.wasm) at rust_begin_unwind (:8080/index-1c2f9c7ca7558b49_bg.wasm) at core::panicking::panic_fmt::h6314b5c91abe7349 (:8080/index-1c2f9c7ca7558b49_bg.wasm) at core::panicking::assert_failed_inner::h35b0f7f5a33c494e (:8080/index-1c2f9c7ca7558b49_bg.wasm) at core::panicking::assert_failed::h87dfa277385a8e60 (:8080/index-1c2f9c7ca7558b49_bg.wasm) at egui_glow::painter::Painter::new::h16775fcfecba5b65 (:8080/index-1c2f9c7ca7558b49_bg.wasm) ```
emilk commented 2 years ago

Can you try removing the code in fn is_safari_and_webkit_gtk in egui_web/src/lib.rs and see if it helps? I believe that is the INVALID_ENUM: getParameter being warned about.

It used to be protected by

if gl
        .get_extension("WEBGL_debug_renderer_info")
        .unwrap()
        .is_some()
    {

but I recently removed that (in https://github.com/emilk/egui/pull/1020) because it caused warnings in Firefox ("WEBGL_debug_renderer_info is deprecated in Firefox and will be removed.").

yusdacra commented 2 years ago

Commenting out the code to return false does make the application run. However it still uses WebGL1, but it used to work with WebGL2. I don't get any other warnings or errors about that; only the fallback messages by egui.

emilk commented 2 years ago

Ok, so Chromium requires a check of WEBGL_debug_renderer_info and Firefox doesn't allow it 🙄. Just another day in web-dev. I'll re-add the check for now.

emilk commented 2 years ago

Ok, I found the problem and I'm fixing it!

yusdacra commented 2 years ago

That does indeed fix it. Thanks for the quick fix!