diff --git a/crates/eframe/src/web/events.rs b/crates/eframe/src/web/events.rs index 733e2e561d8..7e2d07a1b28 100644 --- a/crates/eframe/src/web/events.rs +++ b/crates/eframe/src/web/events.rs @@ -890,7 +890,7 @@ impl ResizeObserverContext { let runner_ref = runner_ref.clone(); move |entries: js_sys::Array| { if DEBUG_RESIZE { - // log::info!("ResizeObserverContext callback"); + log::info!("ResizeObserverContext callback"); } // Only call the wrapped closure if the egui code has not panicked if let Some(mut runner_lock) = runner_ref.try_lock() { @@ -919,6 +919,8 @@ impl ResizeObserverContext { if let Err(err) = runner_ref.request_animation_frame() { log::error!("{}", super::string_from_js_value(&err)); }; + } else { + log::warn!("ResizeObserverContext callback: failed to lock runner"); } } }) as Box); diff --git a/crates/eframe/src/web/web_runner.rs b/crates/eframe/src/web/web_runner.rs index 80c9d021dae..9fea500bcc6 100644 --- a/crates/eframe/src/web/web_runner.rs +++ b/crates/eframe/src/web/web_runner.rs @@ -71,24 +71,27 @@ impl WebRunner { canvas.style().set_property("outline", "none")?; } - let text_agent = TextAgent::attach(self)?; + { + // First set up the app runner: + let text_agent = TextAgent::attach(self)?; + let app_runner = + AppRunner::new(canvas.clone(), web_options, app_creator, text_agent).await?; + self.app_runner.replace(Some(app_runner)); + } { let resize_observer = events::ResizeObserverContext::new(self)?; - // This will (eventually) result in a `request_animation_frame` to start the render loop. + // Properly size the canvas. Will also call `self.request_animation_frame()` (eventually) resize_observer.observe(&canvas); self.resize_observer.replace(Some(resize_observer)); } - { - let app_runner = AppRunner::new(canvas, web_options, app_creator, text_agent).await?; - self.app_runner.replace(Some(app_runner)); - } - events::install_event_handlers(self)?; + log::info!("event handlers installed."); + Ok(()) }