Skip to content

fix: putImageData bypassed deferred rendering PageRecorder#1206

Merged
Brooooooklyn merged 3 commits intomainfrom
fix/put-image-data-deferred-rendering
Feb 12, 2026
Merged

fix: putImageData bypassed deferred rendering PageRecorder#1206
Brooooooklyn merged 3 commits intomainfrom
fix/put-image-data-deferred-rendering

Conversation

@Brooooooklyn
Copy link
Owner

@Brooooooklyn Brooooooklyn commented Feb 12, 2026

putImageData wrote directly to the main surface canvas, but getImageData
reads from the PageRecorder's RecordingSurface in deferred mode. This
caused putImageData to have no visible effect since v0.1.89.

The fix routes putImageData through PageRecorder.put_pixels(), which
creates a fresh recording layer with no clip/transform (per HTML spec,
putImageData ignores both). Uses write_pixels_dirty (drawImageRect)
instead of write_pixels (SkCanvas::writePixels) because the latter is
not recordable by SkPictureRecorder.

Co-Authored-By: Claude Opus 4.6 noreply@anthropic.com


Note

Medium Risk
Touches core pixel-writing/render recording paths (Rust + C++ FFI) and changes how putImageData is applied and layered, which could affect compositing behavior across backends. Scope is contained and covered by new regression tests, but still impacts rendering correctness.

Overview
Fixes putImageData in deferred rendering by routing writes through PageRecorder.put_pixels() so pixel updates become visible to getImageData.

Replaces the previous dirty-rect pixel write path with a new skiac_canvas_put_image_data implementation that draws via drawImageRect using kSrc blend mode (pixel replacement) so operations are recordable by SkPictureRecorder and ignore clip/transform as required.

Adds regression tests for #1204 covering basic putImageData and dirty-rect behavior.

Written by Cursor Bugbot for commit f21d664. This will update automatically on new commits. Configure here.

Copy link
Owner Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@Brooooooklyn Brooooooklyn changed the title fix: putImageData bypassed deferred rendering PageRecorder (#1204) fix: putImageData bypassed deferred rendering PageRecorder Feb 12, 2026
@Brooooooklyn Brooooooklyn force-pushed the fix/put-image-data-deferred-rendering branch from 326d59a to e798305 Compare February 12, 2026 09:51
putImageData wrote directly to the main surface canvas, but getImageData
reads from the PageRecorder's RecordingSurface in deferred mode. This
caused putImageData to have no visible effect since v0.1.89.

The fix routes putImageData through PageRecorder.put_pixels(), which
creates a fresh recording layer with no clip/transform (per HTML spec,
putImageData ignores both). Uses write_pixels_dirty (drawImageRect)
instead of write_pixels (SkCanvas::writePixels) because the latter is
not recordable by SkPictureRecorder.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@Brooooooklyn Brooooooklyn force-pushed the fix/put-image-data-deferred-rendering branch from e798305 to bdf086b Compare February 12, 2026 10:06
Address review feedback:
- Add skiac_canvas_put_image_data C++ function using drawImageRect with
  kSrc blend mode for correct pixel replacement per HTML spec. The
  previous write_pixels_dirty used SrcOver which composited with
  existing content instead of replacing it for semi-transparent pixels.
- Extract duplicated state restoration logic (begin_recording + restore
  save_count/clip/transform) into resume_recording() helper, used by
  both promote_layer() and put_pixels().

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@Brooooooklyn Brooooooklyn force-pushed the fix/put-image-data-deferred-rendering branch from 92479ad to c373b94 Compare February 12, 2026 10:21
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

write_pixels_dirty (Rust method, FFI binding, and C++ implementation
skiac_canvas_write_pixels_dirty) had zero callers after the previous
commit replaced all call sites with put_image_data.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@Brooooooklyn Brooooooklyn merged commit ae938a3 into main Feb 12, 2026
40 checks passed
@Brooooooklyn Brooooooklyn deleted the fix/put-image-data-deferred-rendering branch February 12, 2026 11:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Regression: ctx.putImageData() seems broken since 0.1.89

1 participant