emilk / emilk/egui

Web canvas resize loop

Open
#4,699 10 comments 0 reactions 0 assignees View on GitHub
bug docs and examples web
Dominant language
Rust
Stars
30.6k
Forks
2.1k
Avg merge
1d 9h
Merged PRs (30d)
72

Description

**Describe the bug**
https://github.com/emilk/egui/pull/4536 introduced a ResizeObserver-based resizing for the canvas. Testing it with rerun, when the size of the canvas isn't explicitly bounded via CSS, the canvas quickly enters a resize loop where:
1. A first resize entry is fired after the first call to `.observe`. In the callback, the canvas is resized to the measured device pixel size. For instance, if the device pixel ratio is 2 and the canvas size hasn't been explicitly set via CSS, the canvas will be resized from 300x150 (logical pixels) to 600x300 (physical pixels).
2. The resize causes a new resize entry to be fired. This time, the canvas will be resized from 600x300 to 1200x600.
3. etc.
4. This quickly causes rerun/egui to crash from trying to instantiate too large a texture.

Contributor guide

Open the contributing guide

Research direction

Start by tracing the ResizeObserver callback introduced by pull request 4536, including the first call to .observe and the canvas resize path. Reproduce with an unbounded canvas and verify that resizing to the measured device-pixel size no longer triggers an unbounded sequence of resize entries or an oversized texture crash.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust, wasm
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.