perf(web): replace softbuffer canvas present with direct put_image_data#1374
Open
irvingouj@Devolutions (irvingoujAtDevolution) wants to merge 1 commit into
Open
perf(web): replace softbuffer canvas present with direct put_image_data#1374irvingouj@Devolutions (irvingoujAtDevolution) wants to merge 1 commit into
irvingouj@Devolutions (irvingoujAtDevolution) wants to merge 1 commit into
Conversation
The render path converted each dirty region RGBA -> u32 `0RGB`, then let softbuffer repack u32 -> RGBA into a freshly allocated buffer every frame — two pixel passes over the whole surface plus a per-frame allocation. Replace it with the canvas's own 2D context: one copy of the region into a reused RGBA scratch (alpha forced opaque) followed by put_image_data at the region origin. softbuffer is dropped from ironrdp-web (still used by ironrdp-viewer). Mirrors the same fix in IronVNC. Measured with a record/replay draw bench (dev wasm, headless Chromium), draw-stage median: 4K 1706ms -> 83ms (~20x), 1080p 705ms -> 14ms (~50x), with byte-identical canvas output and unchanged framebuffer checksums.
Contributor
Author
|
Same as VNC, remove softbuffer |
Copilot started reviewing on behalf of
irvingouj@Devolutions (irvingoujAtDevolution)
June 12, 2026 21:18
View session
There was a problem hiding this comment.
Pull request overview
This PR updates the ironrdp-web rendering path to remove the softbuffer dependency and present updated regions by uploading RGBA buffers directly to an HTML canvas via CanvasRenderingContext2d::put_image_data, aiming to reduce per-frame work and allocations.
Changes:
- Replaces the softbuffer-based canvas present path with direct
ImageData+put_image_datablits for dirty regions. - Removes the
softbufferdependency fromironrdp-web. - Enables additional
web-sysfeatures needed for 2D canvas rendering (CanvasRenderingContext2d,ImageData).
Reviewed changes
Copilot reviewed 2 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| crates/ironrdp-web/src/canvas.rs | Implements the new 2D-context put_image_data rendering path and removes the softbuffer surface logic. |
| crates/ironrdp-web/Cargo.toml | Drops softbuffer dependency; enables required web-sys features for 2D canvas + ImageData. |
| Cargo.lock | Updates lockfile dependency edges to reflect removal of softbuffer from ironrdp-web. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| }) | ||
| } | ||
|
|
||
| /// Setting width/height resets the canvas backing store; the 2D context persists. |
Comment on lines
43
to
+45
| pub(crate) fn resize(&mut self, width: NonZeroU32, height: NonZeroU32) { | ||
| self.surface.resize(width, height).expect("surface resize"); | ||
| self.width = width; | ||
| self.canvas.set_width(width.get()); | ||
| self.canvas.set_height(height.get()); |
This file contains hidden or 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
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.
What
Removes the
softbufferdependency fromironrdp-weband presents canvas updates via the 2D context'sput_image_datadirectly.Why
The old render path did two full-surface pixel passes per frame (RGBA → u32
0RGB, then softbuffer repacks u32 → RGBA into a freshly allocated buffer) plus a per-frame allocation. The new path does a single copy of each dirty region into a reused RGBA scratch (alpha forced opaque) followed byput_image_dataat the region origin.Perf
Record/replay draw bench (dev wasm, headless Chromium), draw-stage median:
Byte-identical canvas output; unchanged framebuffer checksums. Mirrors the same fix already in IronVNC.
Notes
softbufferis only removed fromironrdp-web;ironrdp-viewer(native) still uses it, so it remains inCargo.lock.CanvasRenderingContext2d+ImageDatafeatures.