-
Notifications
You must be signed in to change notification settings - Fork 6k
Add onUnregistered callback in 'Texture' and 'FlutterTexture' #12695
Conversation
chinmaygarde
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.
Some nits but LGTM otherwise. Now that we have an OpenGL capable test harness, can we also a test that asserts the following:
- Platform registers a texture.
- Platform says a texture frame is available.
- ASSERT: The copy-texture call is made by the engine back to the embedder on the GPU thread.
- Platform releases the texture.
- ASSERT: This new unregistered call is made back to the embedder.
The shell or embedder unittests might be the right test harness for this as it asserts how the platform interacts with this mechanism. Just a suggestion and I'd understand if you want to attempt that in a separate patch.
flow/texture.h
Outdated
| virtual void MarkNewFrameAvailable() = 0; | ||
|
|
||
| // Called on GPU thread. | ||
| virtual void OnUnregistered() = 0; |
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.
OnTextureUnregistered instead. Since a subclass is going to override this, OnUnregistered will read ambiguously in a class that has other non-texture handling responsibilities.
| * Called on the GPU thread. | ||
| */ | ||
| @optional | ||
| - (void)onUnregistered; |
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.
Ditto about the onUnregistered begin too ambiguous. In Objective-C the idiom is to also pass the object as an argument. So something like:
-(void) onTextureUnregistered:(FlutterTexture*) texture;
flow/texture_unittests.cc
Outdated
|
|
||
| ~MockTexture() override = default; | ||
|
|
||
| bool unregistered = false; |
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.
Per naming convention, this needs to be private and have an underscore suffix. You can add a getter to check the assertion.
| bool freeze, | ||
| GrContext* context) override {} | ||
|
|
||
| void OnGrContextCreated() override {} |
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.
Per convention, we note the class that declares the prototype for the method being overridden. So // |flutter::testing::Texture|.
|
@chinmaygarde Added the shell test per your suggestion. The copy-texture call exists only on the embedder, so I didn't add it to the shell_unittest. |
[email protected]:flutter/engine.git/compare/c635d70c7266...21b8224 git log c635d70..21b8224 --no-merges --oneline 2019-10-08 [email protected] Send AccessibilityEvent.TYPE_VIEW_FOCUSED when input focus is set. (flutter/engine#12746) 2019-10-08 [email protected] Fix for a11y crash on iOS (flutter/engine#12990) 2019-10-08 [email protected] Link Semantics Typo (flutter/engine#13009) 2019-10-08 [email protected] [web] Add support for path transform (flutter/engine#12794) 2019-10-08 [email protected] Auto-formatter fixes for BUILD.gn files (flutter/engine#13005) 2019-10-08 [email protected] Unblock SIGPROF on flutter_tester start (flutter/engine#12813) 2019-10-08 [email protected] [web] Update the url when route is replaced (flutter/engine#13003) 2019-10-08 [email protected] Missing link flag (flutter/engine#13001) 2019-10-08 [email protected] Started setting our debug background task id to invalid after completion. (flutter/engine#12999) 2019-10-08 [email protected] Add `onUnregistered` callback in 'Texture' and 'FlutterTexture' (flutter/engine#12695) If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-engine-flutter-autoroll Please CC [email protected] on the revert to ensure that a human is aware of the problem. To report a problem with the AutoRoller itself, please file a bug: https://bugs.chromium.org/p/skia/issues/entry?template=Autoroller+Bug Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+/master/autoroll/README.md
[email protected]:flutter/engine.git/compare/c635d70c7266...21b8224 git log c635d70..21b8224 --no-merges --oneline 2019-10-08 [email protected] Send AccessibilityEvent.TYPE_VIEW_FOCUSED when input focus is set. (flutter/engine#12746) 2019-10-08 [email protected] Fix for a11y crash on iOS (flutter/engine#12990) 2019-10-08 [email protected] Link Semantics Typo (flutter/engine#13009) 2019-10-08 [email protected] [web] Add support for path transform (flutter/engine#12794) 2019-10-08 [email protected] Auto-formatter fixes for BUILD.gn files (flutter/engine#13005) 2019-10-08 [email protected] Unblock SIGPROF on flutter_tester start (flutter/engine#12813) 2019-10-08 [email protected] [web] Update the url when route is replaced (flutter/engine#13003) 2019-10-08 [email protected] Missing link flag (flutter/engine#13001) 2019-10-08 [email protected] Started setting our debug background task id to invalid after completion. (flutter/engine#12999) 2019-10-08 [email protected] Add `onUnregistered` callback in 'Texture' and 'FlutterTexture' (flutter/engine#12695) If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-engine-flutter-autoroll Please CC [email protected] on the revert to ensure that a human is aware of the problem. To report a problem with the AutoRoller itself, please file a bug: https://bugs.chromium.org/p/skia/issues/entry?template=Autoroller+Bug Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+/master/autoroll/README.md
Issue explained in detail here: flutter/flutter#41125
As it for now, when a FlutterTextureRegistry calls unregisterTexture on a non-GPU thread, the FlutterTexture doesn't know when the unregistering ends because the task is posted to the GPU thread.
Plugins like video player needs to know when the texture is unregistered in order to safely destruct the AVPlayer object.
Adding this callback provides a way for FlutterTexture to know when it is unregistered.
A WIP PR in video_player plugin demonstrates how it is used flutter/plugins#2124
Partial fix for flutter/flutter#41125