-
Notifications
You must be signed in to change notification settings - Fork 60
wasm broken: failed to resolve: could not find Context
in platform_impl
#171
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
Comments
* Add new web-based std::fs replacement, localstoragefs: https://github.com/iceiix/localstoragefs * Add std_or_web to switch between std::fs (native) or localstoragefs (web) * Update www readme for new missing glutin/winit links, opens issue #171
A potential way forward: glow, see #34 (comment) |
Context
in platform_impl
With #260 (comment) the new error is:
(same potential solution: https://github.com/grovesNL/glow) |
Update from glutin 0.21.x fork to glutin 0.22.0-alpha5 and corresponding compatible version of winit. This removes our custom temporary wasm_stub branches, back to mainline glutin and winit, and is a step towards WebAssembly compatibility, most importantly merging the game loop and event loops as required by winit _which now supports wasm_. Not yet functional on the web because other web dependencies have to be added, see #171 and #34, but native functionality is preserved. * Update for 0.22 glutin API changes: * Move game logic into event loop, run() replacing poll_events() * Specify fullscreen Borderless mode * Pass generic parameter of Event through handle_window_event * hidpi_factor() replaces get_hidpi_factor() * with_inner_size() replaces with_dimensions() * No longer need to unwrap() LogicalSize * set_cursor_grab/visible() replaces grab/hide_cursor() * Fix modifiers deprecated warnings by destructuring only event fields we use, ignoring the rest with '..' * Remove unnecessary mutability from events_loop * Listen for ModifiersChanged event, fixing deprecated modifiers field * Change to stdweb for web backend, replacing web-sys * Pin to glutin =0.22.0-alpha5 and winit =0.20.0-alpha6
* Add new web-based std::fs replacement, localstoragefs: https://github.com/iceiix/localstoragefs * Add std_or_web to switch between std::fs (native) or localstoragefs (web) * Update www readme for new missing glutin/winit links, opens issue #171
* Add new web-based std::fs replacement, localstoragefs: https://github.com/iceiix/localstoragefs * Add std_or_web to switch between std::fs (native) or localstoragefs (web) * Update www readme for new missing glutin/winit links, opens issue #171
* Add new web-based std::fs replacement, localstoragefs: https://github.com/iceiix/localstoragefs * Add std_or_web to switch between std::fs (native) or localstoragefs (web) * Update www readme for new missing glutin/winit links, opens issue #171
* Add new web-based std::fs replacement, localstoragefs: https://github.com/iceiix/localstoragefs * Add std_or_web to switch between std::fs (native) or localstoragefs (web) * Update www readme for new missing glutin/winit links, opens issue #171
With (#277 and #278?), wasm-pack build now fails with a different error:
|
The git dependency was only for wasm32-unknown-emscripten support: aweinstock314/rust-clipboard#62 but #92 changes to using wasm32-unknown-unknown instead, a better supported path (though still incomplete in this project, see #171)
|
wasm-pack is more broken, see #171 (comment) cargo web start is still broken (#171) but less so
I've been following this project and would love web support. What remains to make stevenarella build able for web? Anything I can do? |
@TheGreatRambler The biggest missing piece is currently WebGL compatibility. I think replacing steven_gl with a cross-platform wrapper would be a good way to solve this. Some more background and notes in #34 I started migrating to glow (GL on Whatever) in #262 but it is very incomplete. If you (or anyone) wants to work on it and can get it working, would be much appreciated. It is a large effort because of the extensive use of raw OpenGL through steven_gl, but switching off directly using OpenGL is (I believe) a necessary prerequisite for web support. After rendering is working on the web, there will probably be a lot of other small compatibility changes needed to make it usable on the web, but rendering is the biggest blocker. |
Glow support (#262) is in, knocking down one of the largest blockers. #442 is still a blocker for rendering with WebGL, however. Lots has changed since I last tested this. Testing
The recent glutin update (#334) is another possible source of incompatibilities.
glow has removed stdweb support: grovesNL/glow@7af2a26 winit supports stdweb but is deprecated and recommends web-sys: https://github.com/rust-windowing/winit#webassembly
glutin https://github.com/rust-windowing/glutin#emscripten-with-asmjs says only glow should be used on the web, not with glutin:
glutin is used in this project for virtual key codes (src/settings.rs, src/ui/mod.rs) and getting the OpenGL context (src/main.rs) / event loop. Example of web-sys replacement for creating a WebGL2 context: https://github.com/grovesNL/glow/blob/main/examples/hello/src/main.rs#L6 |
A small step for #446 🕸️ Web support, use web-sys to interface to the web. Previously, we would try to use glutin on the web, which is not supported; now glutin is only used on native: fixes #171 could not find Context in platform_impl. winit is still used on both, but the GL context is created with web-sys and glow (on the web), and created with glutin and used with glow (on native). stdweb is no longer used, being replaced by web-sys. Substantial refactoring to allow reusing the code between web/native: * settings: use VirtualKeyCode from winit, not reexported from glutin * std_or_web: remove broken localstoragefs/stdweb, add File placeholder * render: disable skin_thread on wasm since we don't have threads * gl: use glow types in gl wrapper (integers in native, but Web*Key in web) * gl: web-sys WebGlUniformLocation does not implement Copy trait, so glow::UniformLocation doesn't so gl::Uniform can't * gl: refactor context initialization, pass glow::Context to gl::init for consistency between native/web * gl: update to glow with panicking tex_image_2d_multisample web-sys wrapper * glsl: use shader version in GLSL for WebGL 2 and OpenGL 3.2 * shaders: add explicit float/int type conversions, required for WebGL * shaders: specify mediump precision, required for WebGL * shaders: specify fragment shader output locations for WebGL * main: refactor handle_window_event to take a winit window, not glutin context * main: handle resize outside of handle_window_event since it updates the glutin window (the only event which does this) * main: use winit events in handle_window_event not reexported glutin events * main: refactor game loop handling into tick_all() * main: create winit window for WebGL, and use winit_window from glutin * main: restore console_error_panic_hook, mistakingly removed in (#260) * main: remove force setting env RUST_BACKTRACE=1, no longer can set env on web * www: index.js: fix wasm import path * www: npm update, npm audit fix * www: update readme to link to status on #446 🕸️ Web support
A small step for #446 🕸️ Web support, use web-sys to interface to the web. Previously, we would try to use glutin on the web, which is not supported; now glutin is only used on native: fixes #171 could not find Context in platform_impl. winit is still used on both, but the GL context is created with web-sys and glow (on the web), and created with glutin and used with glow (on native). stdweb is no longer used, being replaced by web-sys. Substantial refactoring to allow reusing the code between web/native: * settings: use VirtualKeyCode from winit, not reexported from glutin * std_or_web: remove broken localstoragefs/stdweb, add File placeholder * render: disable skin_thread on wasm since we don't have threads * gl: use glow types in gl wrapper (integers in native, but Web*Key in web) * gl: web-sys WebGlUniformLocation does not implement Copy trait, so glow::UniformLocation doesn't so gl::Uniform can't * gl: refactor context initialization, pass glow::Context to gl::init for consistency between native/web * gl: update to glow with panicking tex_image_2d_multisample web-sys wrapper * glsl: use shader version in GLSL for WebGL 2 and OpenGL 3.2 * shaders: add explicit float/int type conversions, required for WebGL * shaders: specify mediump precision, required for WebGL * shaders: specify fragment shader output locations for WebGL * main: refactor handle_window_event to take a winit window, not glutin context * main: handle resize outside of handle_window_event since it updates the glutin window (the only event which does this) * main: use winit events in handle_window_event not reexported glutin events * main: refactor game loop handling into tick_all() * main: create winit window for WebGL, and use winit_window from glutin * main: restore console_error_panic_hook, mistakingly removed in (#260) * main: remove force setting env RUST_BACKTRACE=1, no longer can set env on web * www: index.js: fix wasm import path * www: npm update, npm audit fix * www: update readme to link to status on #446 🕸️ Web support
After fixing #115 #166 std::fs (continuing #92 wasm), a new problem arises: glutin/winit doesn't support the web yet:
inline417.js:3 Panic error message: not yet implemented: Glutin-Blank: Platform unsupported
inline418.js:3 Encountered a panic! __cargo_web_snippet_dc2fd915bd92f9e9c6a3bd15174f1414eee3dbaf @ inline418.js:3 __wbg_cargowebsnippetdc2fd915bd92f9e9c6a3bd15174f1414eee3dbaf_ce624dc8989b7508 @ stevenarella.js:262 __wbg_cargowebsnippetdc2fd915bd92f9e9c6a3bd15174f1414eee3dbaf_ce624dc8989b7508 @ bootstrap.js:122 stdweb::webcore::initialization::initialize::{{closure}}::hfaf8b55158d3d793 @ wasm-002ccbc2-399:21 std::panicking::rust_panic_with_hook::h5d8808384a53a826 @ wasm-002ccbc2-378:115 std::panicking::continue_panic_fmt::h821bed92a14cf5d5 @ wasm-002ccbc2-550:52 std::panicking::begin_panic_fmt::h83a0a8c60964976b @ wasm-002ccbc2-609:42 glutin::platform::platform::Context::new_windowed::h12dee54925d08191 @ wasm-002ccbc2-534:54 stevenarella::main2::hcc90ca13771299f1 @ wasm-002ccbc2-70:761 stevenarella::main::hbc764074c370a7d5 @ wasm-002ccbc2-949:2 main @ wasm-002ccbc2-950:2 main @ stevenarella.js:63 (anonymous) @ index.js:5 ./index.js @ 0.bootstrap.js:178 __webpack_require__ @ bootstrap.js:165 Promise.then (async) (anonymous) @ bootstrap.js:4 ./bootstrap.js @ bootstrap.js:344 __webpack_require__ @ bootstrap.js:165 (anonymous) @ client:2 0 @ bootstrap.js:631 __webpack_require__ @ bootstrap.js:165 (anonymous) @ bootstrap.js:332 (anonymous) @ bootstrap.js:335 inline417.js:3 Panic error message: not yet implemented: Glutin-Blank: Platform unsupported __cargo_web_snippet_97495987af1720d8a9a923fa4683a7b683e3acd6 @ inline417.js:3 __wbg_cargowebsnippet97495987af1720d8a9a923fa4683a7b683e3acd6_4d6a8b798885113c @ stevenarella.js:258 __wbg_cargowebsnippet97495987af1720d8a9a923fa4683a7b683e3acd6_4d6a8b798885113c @ bootstrap.js:125 stdweb::webcore::initialization::initialize::{{closure}}::hfaf8b55158d3d793 @ wasm-002ccbc2-399:72 std::panicking::rust_panic_with_hook::h5d8808384a53a826 @ wasm-002ccbc2-378:115 std::panicking::continue_panic_fmt::h821bed92a14cf5d5 @ wasm-002ccbc2-550:52 std::panicking::begin_panic_fmt::h83a0a8c60964976b @ wasm-002ccbc2-609:42 glutin::platform::platform::Context::new_windowed::h12dee54925d08191 @ wasm-002ccbc2-534:54 stevenarella::main2::hcc90ca13771299f1 @ wasm-002ccbc2-70:761 stevenarella::main::hbc764074c370a7d5 @ wasm-002ccbc2-949:2 main @ wasm-002ccbc2-950:2 main @ stevenarella.js:63 (anonymous) @ index.js:5 ./index.js @ 0.bootstrap.js:178 __webpack_require__ @ bootstrap.js:165 Promise.then (async) (anonymous) @ bootstrap.js:4 ./bootstrap.js @ bootstrap.js:344 __webpack_require__ @ bootstrap.js:165 (anonymous) @ client:2 0 @ bootstrap.js:631 __webpack_require__ @ bootstrap.js:165 (anonymous) @ bootstrap.js:332 (anonymous) @ bootstrap.js:335 inline416.js:3 Panic location: /Users/admin/.cargo/git/checkouts/glutin-390166537a874d6b/1e48d32/glutin/src/platform/blank/mod.rs:32 __cargo_web_snippet_72fc447820458c720c68d0d8e078ede631edd723 @ inline416.js:3 __wbg_cargowebsnippet72fc447820458c720c68d0d8e078ede631edd723_60857d6a328c5ce1 @ stevenarella.js:254 __wbg_cargowebsnippet72fc447820458c720c68d0d8e078ede631edd723_60857d6a328c5ce1 @ bootstrap.js:128 stdweb::webcore::initialization::initialize::{{closure}}::hfaf8b55158d3d793 @ wasm-002ccbc2-399:104 std::panicking::rust_panic_with_hook::h5d8808384a53a826 @ wasm-002ccbc2-378:115 std::panicking::continue_panic_fmt::h821bed92a14cf5d5 @ wasm-002ccbc2-550:52 std::panicking::begin_panic_fmt::h83a0a8c60964976b @ wasm-002ccbc2-609:42 glutin::platform::platform::Context::new_windowed::h12dee54925d08191 @ wasm-002ccbc2-534:54 stevenarella::main2::hcc90ca13771299f1 @ wasm-002ccbc2-70:761 stevenarella::main::hbc764074c370a7d5 @ wasm-002ccbc2-949:2 main @ wasm-002ccbc2-950:2 main @ stevenarella.js:63 (anonymous) @ index.js:5 ./index.js @ 0.bootstrap.js:178 __webpack_require__ @ bootstrap.js:165 Promise.then (async) (anonymous) @ bootstrap.js:4 ./bootstrap.js @ bootstrap.js:344 __webpack_require__ @ bootstrap.js:165 (anonymous) @ client:2 0 @ bootstrap.js:631 __webpack_require__ @ bootstrap.js:165 (anonymous) @ bootstrap.js:332 (anonymous) @ bootstrap.js:335 bootstrap.js:5 Error importing `index.js`: RuntimeError: unreachable at __rust_start_panic (wasm-function[1045]:1) at rust_panic (wasm-function[704]:31) at std::panicking::rust_panic_with_hook::h5d8808384a53a826 (wasm-function[378]:304) at std::panicking::continue_panic_fmt::h821bed92a14cf5d5 (wasm-function[550]:116) at std::panicking::begin_panic_fmt::h83a0a8c60964976b (wasm-function[609]:95) at glutin::platform::platform::Context::new_windowed::h12dee54925d08191 (wasm-function[534]:120) at stevenarella::main2::hcc90ca13771299f1 (wasm-function[70]:1695) at stevenarella::main::hbc764074c370a7d5 (wasm-function[949]:1) at main (wasm-function[950]:1) at Module.main (webpack:///../pkg/stevenarella.js?:63:66)#34 Investigate rendering backends, such as gfx-rs or wgpu
https://github.com/iceiix/stevenarella/tree/master/www
The text was updated successfully, but these errors were encountered: