-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix crash on request_animation_frame
when destroying web runner
#4169
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 tasks
emilk
approved these changes
Mar 14, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Much nicer ⭐
request_animation_frame
when destroying web runner
emilk
pushed a commit
to rerun-io/rerun
that referenced
this pull request
Mar 17, 2024
Snippets™️ (formerly known as "code examples" or "doc examples") are now built on CI together with Examples™️, and uploaded to the same place. Also includes some changes to example screenshots (adding `data-inline-viewer` attributes), and updating the egui rev to fix a bug - Blocked by emilk/egui#4169 ### Checklist * [x] I have read and agree to [Contributor Guide](https://github.com/rerun-io/rerun/blob/main/CONTRIBUTING.md) and the [Code of Conduct](https://github.com/rerun-io/rerun/blob/main/CODE_OF_CONDUCT.md) * [x] I've included a screenshot or gif (if applicable) * [x] I have tested the web demo (if applicable): * Using newly built examples: [app.rerun.io](https://app.rerun.io/pr/5438/index.html) * Using examples from latest `main` build: [app.rerun.io](https://app.rerun.io/pr/5438/index.html?manifest_url=https://app.rerun.io/version/main/examples_manifest.json) * Using full set of examples from `nightly` build: [app.rerun.io](https://app.rerun.io/pr/5438/index.html?manifest_url=https://app.rerun.io/version/nightly/examples_manifest.json) * [x] The PR title and labels are set such as to maximize their usefulness for the next release's CHANGELOG * [x] If applicable, add a new check to the [release checklist](https://github.com/rerun-io/rerun/blob/main/tests/python/release_checklist)! - [PR Build Summary](https://build.rerun.io/pr/5438) - [Docs preview](https://rerun.io/preview/27f898acc6efda581ce2a4f540f73dc68ef50578/docs) <!--DOCS-PREVIEW--> - [Examples preview](https://rerun.io/preview/27f898acc6efda581ce2a4f540f73dc68ef50578/examples) <!--EXAMPLES-PREVIEW--> - [Recent benchmark results](https://build.rerun.io/graphs/crates.html) - [Wasm size tracking](https://build.rerun.io/graphs/sizes.html)
hacknus
pushed a commit
to hacknus/egui
that referenced
this pull request
Oct 30, 2024
…ilk#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.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Previously, any frames in flight (
requestAnimationFrame
) on web were not being cancelled (cancelAnimationFrame
) whenWebRunner::destroy
was called. If a user calleddestroy
, 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:
canvas_id
1WebRunner
andcancelAnimationFrame
is called on it inside ofWebRunner::destroy
2Footnotes
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. ↩There is only ever one frame in flight, so we store it directly as a scalar field. ↩