[vector_graphics] Fix uncaught StateError in useHtmlRenderObject on CanvasKit / iOS Safari#11685
Merged
auto-submit[bot] merged 1 commit intoMay 11, 2026
Conversation
Contributor
There was a problem hiding this comment.
Code Review
This pull request updates the vector_graphics package to version 1.2.1. It modifies useHtmlRenderObject in render_object_selection.dart to catch StateError during toImageSync calls, specifically addressing a GPU pixel-read failure observed on CanvasKit in iOS 18.7. The CHANGELOG.md and pubspec.yaml have been updated to reflect this version change and fix. I have no feedback to provide.
4b38cf7 to
d63fe77
Compare
…tmlRenderObject
useHtmlRenderObject() probes toImageSync to decide whether to use the
HTML compatibility render object. Until now it caught only
UnsupportedError, which covered the original HTML renderer. Production
telemetry now shows two more failure modes from the same probe call on
CanvasKit / Mobile Safari (iOS 18.7):
* StateError: "Unable to convert read pixels from SkImage" thrown
when readPixels fails at runtime.
* NoSuchMethodError: "Null check operator used on a null value"
surfaced from canvaskit.js wasm internals via
Surface.createOrUpdateSurface.
Add catch clauses for both. Each one is the same observed-in-production
signal that the renderer cannot honor toImageSync, so the response is
identical to the UnsupportedError path — fall back to the HTML render
object.
The failure mode is only triggered by specific CanvasKit / iOS Safari
combinations and cannot be reproduced deterministically in a unit test
against the host renderer. Verified against production telemetry on iOS
18.7 Safari, where both exception types reach users today.
Fixes flutter/flutter#186333
creatorpiyush
pushed a commit
to creatorpiyush/packages
that referenced
this pull request
Jun 10, 2026
…anvasKit / iOS Safari (flutter#11685) ## Description `useHtmlRenderObject()` only caught `UnsupportedError` when probing `toImageSync`. CanvasKit on Mobile Safari (iOS 18.7) throws a `StateError` ("Unable to convert read pixels from SkImage") instead, which escapes the `try/catch` and crashes the widget subtree. This change treats both `UnsupportedError` and `StateError` as "use the HTML render object" — the function only exists to probe and pick a fallback. ## Related Issues Fixes flutter/flutter#186333 ## Tests The failure mode is only triggered by specific CanvasKit / Mobile Safari combinations (observed on iOS 18.7) and cannot be reproduced deterministically in a unit test against the host's renderer. Validated against production telemetry on iOS 18.7 Safari, where this exception is currently uncaught and reaches users. All existing `vector_graphics` and `vector_graphics_compiler` tests still pass after the change.
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.
Description
useHtmlRenderObject()only caughtUnsupportedErrorwhen probingtoImageSync. CanvasKit on Mobile Safari (iOS 18.7) throws aStateError("Unable to convert read pixels from SkImage") instead, which escapes the
try/catchand crashes the widget subtree.This change treats both
UnsupportedErrorandStateErroras"use the HTML render object" — the function only exists to probe and
pick a fallback.
Related Issues
Fixes flutter/flutter#186333
Tests
The failure mode is only triggered by specific CanvasKit / Mobile Safari
combinations (observed on iOS 18.7) and cannot be reproduced deterministically
in a unit test against the host's renderer. Validated against production
telemetry on iOS 18.7 Safari, where this exception is currently uncaught and
reaches users.
All existing
vector_graphicsandvector_graphics_compilertests stillpass after the change.
Pre-launch Checklist
dart format.)pubspec.yamlwith an appropriate new version.CHANGELOG.mdto add a description of the change.///).