wgpu_glyph
wgpu_glyph copied to clipboard
Broken text rendering on wasm32 target in Firefox
I have managed to compile hello
example to wasm32
target with some changes to winit initialization, however, when trying to render new text on the next frame, part of the text disappear (e.g I just render text with content that changes each frame with format!("Frame {}!, counter)
).
I have modified the example I'm my fork to help reproduce the issue: https://github.com/pacmancoder/wgpu_glyph/tree/issue-report/wasm32-text-rendering
UPD: Reproduces only on Firefox (v93)
Steps to run example on wasm32
# 0. Install prerequisites
cargo install wasm-bindgen-cli https
# 1. Compile wasm module
cargo build --example hello --target=wasm32-unknown-unknown
# 2. Invoke wasm-bindgen
wasm-bindgen target/wasm32-unknown-unknown/debug/examples/hello.wasm --out-dir . --target web --no-typescript
# 3. run http server
http
# 4. Open 127.0.0.1:8000 in browser
Results can be compared with non-wasm32 build of example cargo run --example hello
Normal behavior; Compiled for non-wasm32 target
Text artifacts of wasm32 target, part of the text is missing
Not sure yet if it is related to wgpu
or wgpu_glyph
implementation.
UPD: Huh... Looks like it reproduces only on Firefox (v93)....
When wgpu
is updated to thje latest master (https://github.com/gfx-rs/wgpu/commit/d46c39af1d0b6be3fc0ed05b5b262cb734b29a96) It produces even more bizarre results (still, only on Firefox)
UPD1: Decreasing initial cache cache makes this bug even funnier (yep, still reproduces only in Firefox):
WARNING: Quickli changing images (gif)
UPD2: Set draw_cache_align_4x4(true)
(I missed the fact that is should be enabled on WebGL), but still, no visible change.
- Are we sure the example is leveraging WebGL and not the experimental WebGPU API?
- The example in your fork does not match the screenshots you shared. There is no "Frame #" text in the source.
- If I had to guess, I'd say that there is something up with the cache upload logic here: https://github.com/hecrj/wgpu_glyph/blob/cd6f154db0e7dd8231fdd34fcac470f975c825d7/src/pipeline/cache.rs#L60-L121
@hecrj Wow, I forgot to push local changes to the fork 🥴... Now it is in place, sorry for that!
Well, I explicitly ask wgpu
for wgpu::Backends::GL
backend, so unless if something is completely broken in wgpu, it should use WebGL, I guess...
Yea, my bet is too on the broken caching logic, but I not yet figured out what shat is specifically wrong with it...
Similar problems were encountered when i was using iced v0.3.0. the last few words are not rendered.
not the web but default wgpu