-
Notifications
You must be signed in to change notification settings - Fork 6k
[canvaskit] Release overlays to the cache once they have been used #27977
[canvaskit] Release overlays to the cache once they have been used #27977
Conversation
|
|
||
| // Returns [true] if this [surface] is in the DOM. | ||
| static bool _isInDom(Surface surface) { | ||
| return surface.htmlElement.parent != null; |
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.
Not sure if it's any better but there's also the isConnected: https://developer.mozilla.org/en-US/docs/Web/API/Node/isConnected
I'm also getting a feeling that the fact that we're reading back from the DOM indicates a design issue somewhere. I feel like we should know whether the surface is in use or not without the readback 🤔 Can't think of any specific harm in this; just a feeling.
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.
I only included it so that I could quickly remove all overlays from the DOM before recreating the scene. A quick check shows that calling remove on an Element that isn't in the DOM is fine, so I'll just get rid of this check.
|
PTAL |
yjbanov
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.
| /// engine to release the surfaces at the end of the frame so they are ready | ||
| /// to be used in the next frame, but still used for painting in the current | ||
| /// frame. | ||
| void releaseSurfaces() { |
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.
nit: how about call it releaseUnusedSurfaces?

Releases overlays back to the cache at the end of the frame so they can be used by platform views in the next frame.
Fixes flutter/flutter#87245
Pre-launch Checklist
writing and running engine tests.
///).If you need help, consider asking for advice on the #hackers-new channel on Discord.