`request_repaint` panics when used from a Web Worker
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 30.6k
- Forks
- 2.1k
- Avg merge
- 1d 9h
- Merged PRs (30d)
- 72
Description
**Describe the bug**
Using `request_repaint` (or any of its variants) from a Web Worker panics. The panic info points here:
https://github.com/emilk/egui/blob/a8501c963dba0f14a8feff28ed91ff245956662c/crates/eframe/src/web/mod.rs#L60-L67
It seems like eframe ends up trying to get the time, but the `now_sec` function uses the JS Window object which isn't available from a Web Worker.
Right now, my workaround is to force my app to run at 60fps continuous during the loading time, instead of repainting when needed.
**Screenshots**

**Desktop (please complete the following information):**
- Chrome 123, Firefox 124
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at crates/eframe/src/web/mod.rs around lines 60-67 and inspect the now_sec function referenced in the report. Reproduce request_repaint from a Web Worker in Chrome or Firefox, then verify that the repaint request no longer panics when the worker lacks a JS Window object.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust, wasm
- Domain
- frontend, web-dev
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100