Skip to content

Manually Revert "fix(web): Fix LateInitializationError in CkSurface and SkwasmSurface (#185116)"#185539

Merged
auto-submit[bot] merged 1 commit into
flutter:masterfrom
eyebrowsoffire:fix_bad_gh_merge
Apr 24, 2026
Merged

Manually Revert "fix(web): Fix LateInitializationError in CkSurface and SkwasmSurface (#185116)"#185539
auto-submit[bot] merged 1 commit into
flutter:masterfrom
eyebrowsoffire:fix_bad_gh_merge

Conversation

@eyebrowsoffire

Copy link
Copy Markdown
Contributor

This reverts commit b38bda1.

This is being reverted because there was a GitHub incident which caused this to be a bad merge (it contains a bunch of unrelated changes which themselves are unintentional reverts of previous commits). We will reland the actual fix cleanly after this merges.

…nd SkwasmSurface (flutter#185116)"

This reverts commit b38bda1.

This is being reverted because there was a GitHub incident which caused this to
be a bad merge (it contains a bunch of unrelated changes which themselves are
unintentional reverts of previous commits). We will reland the actual fix
cleanly after this merges.
@github-actions github-actions Bot added engine flutter/engine related. See also e: labels. platform-web Web applications specifically labels Apr 24, 2026
@eyebrowsoffire eyebrowsoffire added the CICD Run CI/CD label Apr 24, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request implements iterative downscaling for the Flutter web engine to address aliasing artifacts when scaling images below 50% of their original size. It introduces a new image_downscaler.dart utility, a DownscaledImageCache, and integrates these into the CanvasKit and Skwasm backends. Feedback highlights that using the late keyword on nullable fields in CkSurface and SkwasmSurface is problematic and that documentation should be maintained for the newly private _surfaceCreateFn field.

final Completer<void> _initialized = Completer<void>();

Completer<void>? _handledContextLostEvent;
late Completer<void>? _handledContextLostEvent;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

Using the late keyword on a nullable field like Completer<void>? is generally discouraged in Dart and is the likely cause of the LateInitializationError mentioned in the PR title. Since null is a valid initial state for this field, it is safer to initialize it to null (which is the default for nullable fields) rather than using late. This ensures that accessing the field before it is explicitly assigned a Completer returns null instead of throwing an exception.

Suggested change
late Completer<void>? _handledContextLostEvent;
Completer<void>? _handledContextLostEvent;

BitmapSize _currentSize = const BitmapSize(1, 1);
Completer<void> _initializedCompleter;
Completer<void>? _handledContextLostEvent;
late Completer<void>? _handledContextLostEvent;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

Using the late keyword on a nullable field like Completer<void>? is generally discouraged in Dart and is the likely cause of the LateInitializationError mentioned in the PR title. Since null is a valid initial state for this field, it is safer to initialize it to null (which is the default for nullable fields) rather than using late. This ensures that accessing the field before it is explicitly assigned a Completer returns null instead of throwing an exception.

Suggested change
late Completer<void>? _handledContextLostEvent;
Completer<void>? _handledContextLostEvent;

/// A function that creates a new surface of type [C] using a [CanvasProvider] of type [D].
@visibleForTesting
final C Function(D) surfaceCreateFn;
final C Function(D) _surfaceCreateFn;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

Although this field has been made private, it is still helpful to maintain its documentation to explain its purpose, especially since it was previously documented. According to the Flutter style guide (Rule 67), /// should be used for public-quality documentation even on private members.

Suggested change
final C Function(D) _surfaceCreateFn;
/// A function that creates a new surface of type [C] using a [CanvasProvider] of type [D].
final C Function(D) _surfaceCreateFn;
References
  1. Use /// for public-quality documentation, even on private members. (link)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CICD Run CI/CD engine flutter/engine related. See also e: labels. platform-web Web applications specifically

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants