Skip to content

Fix wasm compilation/rendering#1079

Open
Fabi019 wants to merge 4 commits into
lapce:mainfrom
Fabi019:wasm-fix
Open

Fix wasm compilation/rendering#1079
Fabi019 wants to merge 4 commits into
lapce:mainfrom
Fabi019:wasm-fix

Conversation

@Fabi019

@Fabi019 Fabi019 commented Jun 4, 2026

Copy link
Copy Markdown

Thank you for this great UI library! While trying it out in a WASM environment I found and fixed some small issues:

  • Compilation errors due to some non wasm compatible types used (muda::Menu, std::time::Instant)
  • No render output due to self.paint_state not getting set to Initialized without paint called
  • Invisible text on label/buttons in the webgpu example -> Manually set the font_family to "Fira Sans"

@umbrageodotus

Copy link
Copy Markdown

LGTM

Comment thread src/window/handle.rs Outdated
Comment on lines +791 to +792
#[cfg(target_arch = "wasm32")]
let renderer_ready = true;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you speak to the accuracy of doing this. Is this always true?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

During testing I noticed that when setting render_ready to always true the paint_state was in pending for some cycles and then got to initialized. Without, the paint_state was always stuck in pending. While looking at it again now, I suspect the actual reason might be because the last_presented_at only gets set inside the condition. So when renderer_ready is false render_frame gets called without any/very low delay in between thus preventing the initialization. To confirm, I moved the self.last_presented_at = Instant::now(); outside of the condition and with that it also works with the original renderer_ready flag. Maybe that would be the better fix instead?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be but

@jrmoulton

Copy link
Copy Markdown
Collaborator

Thanks for doing this! Just one question

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants