From 95275bc2fdd8532707a609a33d7d530ecf2ff713 Mon Sep 17 00:00:00 2001 From: Fabi019 Date: Thu, 4 Jun 2026 15:13:48 +0200 Subject: [PATCH 1/4] Fix wasm compilation --- src/app/mod.rs | 3 ++- src/event/dispatch.rs | 3 ++- src/window/handle.rs | 3 ++- src/window/state.rs | 3 ++- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/app/mod.rs b/src/app/mod.rs index f21c58df8..d274d22e4 100644 --- a/src/app/mod.rs +++ b/src/app/mod.rs @@ -29,6 +29,7 @@ use crate::{ action::{Timer, TimerToken}, inspector::{Capture, profiler::Profile}, platform::clipboard::Clipboard, + platform::menu_types::Menu, view::IntoView, window::{WindowConfig, WindowCreation}, }; @@ -107,7 +108,7 @@ pub enum AppEvent { Reopen { has_visible_windows: bool }, } -pub(crate) struct MenuWrapper(pub(crate) muda::Menu); +pub(crate) struct MenuWrapper(pub(crate) Menu); // SAFETY: these unsafe wappers are needed so that we can send the muda memu. // The muda menu internally uses RC on a String ID and it's Vec of children. // This unsafe wrapper is memory safe but the race condition could potentially (unlikely) diff --git a/src/event/dispatch.rs b/src/event/dispatch.rs index 243c999bb..51a49db85 100644 --- a/src/event/dispatch.rs +++ b/src/event/dispatch.rs @@ -1,6 +1,6 @@ //! Event dispatch logic for handling events through the view tree. -use std::{rc::Rc, sync::LazyLock, time::Instant}; +use std::{rc::Rc, sync::LazyLock}; use peniko::kurbo::{Affine, Point, Rect}; use smallvec::SmallVec; @@ -25,6 +25,7 @@ use crate::{ DragEvent, DragToken, Event, FocusEvent, InteractionEvent, Phase, PointerCaptureEvent, WindowEvent, drag_state::DragEventDispatch, dropped_file::FileDragEvent, path::hit_test, }, + platform::time::Instant, style::{StyleSelector, StyleSelectors, recalc::StyleReason}, view::{VIEW_STORAGE, View}, window::WindowState, diff --git a/src/window/handle.rs b/src/window/handle.rs index de5a87e4c..7206b2d5f 100644 --- a/src/window/handle.rs +++ b/src/window/handle.rs @@ -594,7 +594,7 @@ impl WindowHandle { // Capture a single timestamp for the entire style pass. // All views in this frame see the same `now`, which is both cheaper // (avoids per-view syscall) and more correct (no sub-frame jitter). - self.window_state.frame_start = std::time::Instant::now(); + self.window_state.frame_start = Instant::now(); // Loop until no more views need styling // This handles the case where styling a parent marks children dirty @@ -1228,6 +1228,7 @@ impl WindowHandle { pos, }); } + #[cfg(not(target_arch = "wasm32"))] UpdateMessage::WindowMenu { menu } => { self.window_menu_actions.clear(); let (menu, registry) = menu.build(); diff --git a/src/window/state.rs b/src/window/state.rs index bb95030b3..2a7156e4c 100644 --- a/src/window/state.rs +++ b/src/window/state.rs @@ -1,4 +1,4 @@ -use std::{cell::RefCell, collections::HashMap, time::Instant}; +use std::{cell::RefCell, collections::HashMap}; use crate::{ action::exec_after_animation_frame, @@ -27,6 +27,7 @@ use crate::{ event::{DragTracker, Event, WindowEvent, clear_hit_test_cache}, layout::responsive::{GridBreakpoints, ScreenSizeBp}, message::UpdateMessage, + platform::time::Instant, style::{CursorStyle, Style, StyleSelector, theme::default_theme}, view::{LayoutNodeCx, MeasureCx, VIEW_STORAGE, ViewId}, }; From 7ef680661457d762d739c55e93aa28a0c76ebc6a Mon Sep 17 00:00:00 2001 From: Fabi019 Date: Thu, 4 Jun 2026 15:14:57 +0200 Subject: [PATCH 2/4] Fix wasm rendering --- src/window/handle.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/window/handle.rs b/src/window/handle.rs index 7206b2d5f..3ef7498c7 100644 --- a/src/window/handle.rs +++ b/src/window/handle.rs @@ -786,7 +786,10 @@ impl WindowHandle { } pub(crate) fn render_frame(&mut self) { + #[cfg(not(target_arch = "wasm32"))] let renderer_ready = matches!(self.paint_state, PaintState::Initialized { .. }); + #[cfg(target_arch = "wasm32")] + let renderer_ready = true; if self.window_state.request_paint && renderer_ready { self.window_state.request_paint = false; self.paint(); From c6161b3101a7c5ed94e483ca5caeb59e6dc0f5c2 Mon Sep 17 00:00:00 2001 From: Fabi019 Date: Thu, 4 Jun 2026 15:16:01 +0200 Subject: [PATCH 3/4] Fix webgpu example text rendering --- examples/webgpu/src/lib.rs | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/examples/webgpu/src/lib.rs b/examples/webgpu/src/lib.rs index c4e9fbabe..034248613 100644 --- a/examples/webgpu/src/lib.rs +++ b/examples/webgpu/src/lib.rs @@ -22,15 +22,22 @@ pub fn app_view() -> impl IntoView { // Create a vertical layout ( // The counter value updates automatically, thanks to reactivity - Label::derived(move || format!("Value: {}", counter.get())), + Label::derived(move || format!("Value: {}", counter.get())) + .style(|s| s.font_family("Fira Sans".to_owned())), // Create a horizontal layout ( - "Increment".class(ButtonClass).action(move || { - counter.update(|value| *value += 1); - }), - "Decrement".class(ButtonClass).action(move || { - counter.update(|value| *value -= 1); - }), + "Increment" + .class(ButtonClass) + .style(|s| s.font_family("Fira Sans".to_owned())) + .action(move || { + counter.update(|value| *value += 1); + }), + "Decrement" + .class(ButtonClass) + .style(|s| s.font_family("Fira Sans".to_owned())) + .action(move || { + counter.update(|value| *value -= 1); + }), ), ) .style(|s| s.flex_col()) From 9612f49e7619a326e4209639c083f3967eac8f13 Mon Sep 17 00:00:00 2001 From: Fabi019 Date: Mon, 8 Jun 2026 21:13:18 +0200 Subject: [PATCH 4/4] Always update last_presented_at time --- src/window/handle.rs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/window/handle.rs b/src/window/handle.rs index 3ef7498c7..6c43516bf 100644 --- a/src/window/handle.rs +++ b/src/window/handle.rs @@ -786,15 +786,12 @@ impl WindowHandle { } pub(crate) fn render_frame(&mut self) { - #[cfg(not(target_arch = "wasm32"))] let renderer_ready = matches!(self.paint_state, PaintState::Initialized { .. }); - #[cfg(target_arch = "wasm32")] - let renderer_ready = true; if self.window_state.request_paint && renderer_ready { self.window_state.request_paint = false; self.paint(); - self.last_presented_at = Instant::now(); } + self.last_presented_at = Instant::now(); if self.live_resize_active() { self.window_state.schedule_paint(self.id);