-
Notifications
You must be signed in to change notification settings - Fork 28.7k
[engine] dont double free surface texture interop objects. #170284
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@@ -55,6 +55,7 @@ void SurfaceTextureExternalTextureGLImpeller::ProcessFrame( | |||
|
|||
void SurfaceTextureExternalTextureGLImpeller::Detach() { | |||
SurfaceTextureExternalTexture::Detach(); | |||
texture_->Leak(); |
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.
Let's leave a comment mentioning the docstring saying that the detach will collect the handle.
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
@@ -229,6 +230,10 @@ TextureGLES::~TextureGLES() { | |||
} | |||
} | |||
|
|||
void TextureGLES::Leak() { | |||
handle_ = HandleGLES::DeadHandle(); |
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.
Does ReactorGLES::CollectHandle
handle a DeadHandle
? We should just add an early return in that case since we'll be acquiring locks and such.
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.
Added one.
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
autosubmit label was removed for flutter/flutter/170284, because - The status or check suite Linux docs_test has failed. Please fix the issues identified (or deflake) before re-applying this label. |
autosubmit label was removed for flutter/flutter/170284, because - The status or check suite Linux build_android_host_app_with_module_aar has failed. Please fix the issues identified (or deflake) before re-applying this label. |
Fixes #152459
I suspect the double free is related to #162147 .
With the Impeller backend, the second free is performed by the reactor and comes only after the application has returned to the foreground. This increaases the likelyhood that we nuke a handle that is in active use by another part of the system.
Since SurfaceTexture:: detachFromGLContext is documented as releasing the texture, we don't need to free it at all and can "leak" it on our side.