egui/crates/eframe/src/web
Jan Procházka c5eaba43cd
Fix crash on `request_animation_frame` when destroying web runner (#4169)
Previously, any frames in flight (`requestAnimationFrame`) on web were
not being cancelled (`cancelAnimationFrame`) when `WebRunner::destroy`
was called. If a user called `destroy`, then immediately removed the
canvas from the DOM, eframe could panic with a "failed to find (canvas)
element by id" error message.

This PR changes two things:
- The canvas element is directly referenced everywhere it's needed
instead of being looked up by `canvas_id`[^1]
- The RAF handle is stored in `WebRunner` and `cancelAnimationFrame` is
called on it inside of `WebRunner::destroy`[^2]

[^1]: The WebGL/WGPU backends were already holding onto the canvas (and
associated GPU context), so the change is just converting all the
`get_element_by_id` lookups to retrieve the canvas from the web runner
handle.

[^2]: There is only ever one frame in flight, so we store it directly as
a scalar field.
2024-03-14 10:26:34 +01:00
..
app_runner.rs Fix crash on `request_animation_frame` when destroying web runner (#4169) 2024-03-14 10:26:34 +01:00
backend.rs eframe web: Don't throw away frames on click/copy/cut (#3623) 2023-11-24 10:08:43 +01:00
events.rs Fix crash on `request_animation_frame` when destroying web runner (#4169) 2024-03-14 10:26:34 +01:00
input.rs Fix crash on `request_animation_frame` when destroying web runner (#4169) 2024-03-14 10:26:34 +01:00
mod.rs Fix crash on `request_animation_frame` when destroying web runner (#4169) 2024-03-14 10:26:34 +01:00
panic_handler.rs Improve documentation of `eframe`, especially for wasm32 (#3295) 2023-09-04 09:55:47 +02:00
screen_reader.rs Remove dependency on `tts` (#3651) 2023-11-28 10:46:18 +01:00
storage.rs Improve documentation of `eframe`, especially for wasm32 (#3295) 2023-09-04 09:55:47 +02:00
text_agent.rs Fix crash on `request_animation_frame` when destroying web runner (#4169) 2024-03-14 10:26:34 +01:00
web_logger.rs Update wgpu to 0.19 (#3824) 2024-01-19 10:14:13 +01:00
web_painter.rs Fix crash on `request_animation_frame` when destroying web runner (#4169) 2024-03-14 10:26:34 +01:00
web_painter_glow.rs Fix crash on `request_animation_frame` when destroying web runner (#4169) 2024-03-14 10:26:34 +01:00
web_painter_wgpu.rs Fix crash on `request_animation_frame` when destroying web runner (#4169) 2024-03-14 10:26:34 +01:00
web_runner.rs Fix crash on `request_animation_frame` when destroying web runner (#4169) 2024-03-14 10:26:34 +01:00