Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Conversation

@yjbanov
Copy link
Contributor

@yjbanov yjbanov commented Mar 25, 2023

Remove obsolete object caches and introduce a simpler way to manage native objects:

  • Remove the unused SynchronousSkiaObjectCache.
  • Introduce new library native_memory.dart that's smaller and simpler than skia_object_cache.dart.
  • Introduce two types of native object references:
    • UniqueRef a reference with a unique Dart object owner.
    • CountedRef a ref-counted reference with multiple Dart object owners.
  • All native references use GC (via FinalizationRegistry) as a back-up.
  • The new library removes everything related to object resurrection that was needed only in browsers that didn't support FinalizationRegistry. All browsers support it now.
  • Remove the ad hoc SkParagraph cache that predates the introduction of Paragraph.dispose.
  • Rewrite CkParagraph in terms of UniqueRef.
  • Rewrite CkImage in terms of CountedRef; delete SkiaObjectBox.

This PR does not migrate all objects from the old skia_object_cache.dart to native_memory.dart. That would be too big of a change. The migration can be done in multiple smaller PRs.

This also removes a few unnecessary relayouts observed in flutter/flutter#120921, but not all of them (more details in flutter/flutter#120921 (comment))

@flutter-dashboard flutter-dashboard bot added the platform-web Code specifically for the web engine label Mar 25, 2023
@yjbanov yjbanov force-pushed the refs branch 2 times, most recently from 2c0acf7 to c3bafe0 Compare March 25, 2023 19:22
@yjbanov yjbanov marked this pull request as ready for review March 26, 2023 04:35
Copy link
Contributor

@harryterkelsen harryterkelsen left a comment

Choose a reason for hiding this comment

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

We should add a test for when the finalization registry disposes GC'ed objects to test the line I pointed out in my review

if (Instrumentation.enabled) {
Instrumentation.instance.incrementCounter('$_debugOwnerLabel Created');
}
_finalizationRegistry.register(owner, UniqueRef);
Copy link
Contributor

Choose a reason for hiding this comment

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

should this be finalizationRegistry.register(owner, this)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done. PTAL

@yjbanov
Copy link
Contributor Author

yjbanov commented Mar 28, 2023

We should add a test for when the finalization registry disposes GC'ed objects to test the line I pointed out in my review

Done. PTAL.

Copy link
Contributor

@harryterkelsen harryterkelsen left a comment

Choose a reason for hiding this comment

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

LGTM

@yjbanov yjbanov added the autosubmit Merge PR when tree becomes green via auto submit App label Mar 29, 2023
@auto-submit auto-submit bot merged commit c0140ec into flutter:main Mar 29, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Mar 29, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Mar 29, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Mar 29, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Mar 29, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Mar 29, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Mar 29, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Mar 29, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Mar 29, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Mar 29, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Mar 29, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Mar 29, 2023
CaseyHillers added a commit that referenced this pull request Apr 2, 2023
yjbanov pushed a commit that referenced this pull request Apr 2, 2023
…anagement" (#40861)

Reverts #40617

See b/276167870. This is causing a build breakage to Google testing for
all web projects.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

autosubmit Merge PR when tree becomes green via auto submit App platform-web Code specifically for the web engine

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants