-
Notifications
You must be signed in to change notification settings - Fork 6k
[web] remove obsolete object caches; simplify native object management #40617
Conversation
2c0acf7 to
c3bafe0
Compare
harryterkelsen
left a comment
There was a problem hiding this 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); |
There was a problem hiding this comment.
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)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. PTAL
Done. PTAL. |
harryterkelsen
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Remove obsolete object caches and introduce a simpler way to manage native objects:
SynchronousSkiaObjectCache.native_memory.dartthat's smaller and simpler thanskia_object_cache.dart.UniqueRefa reference with a unique Dart object owner.CountedRefa ref-counted reference with multiple Dart object owners.FinalizationRegistry) as a back-up.FinalizationRegistry. All browsers support it now.SkParagraphcache that predates the introduction ofParagraph.dispose.CkParagraphin terms ofUniqueRef.CkImagein terms ofCountedRef; deleteSkiaObjectBox.This PR does not migrate all objects from the old
skia_object_cache.darttonative_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))