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

Add onUnregistered callback in 'Texture' and 'FlutterTexture' #12695

Merged
merged 15 commits into from
Oct 8, 2019

Conversation

cyanglaz
Copy link
Contributor

@cyanglaz cyanglaz commented Sep 30, 2019

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

@cyanglaz cyanglaz marked this pull request as ready for review September 30, 2019 16:44
Copy link
Member

@chinmaygarde chinmaygarde left a 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
@@ -36,6 +36,9 @@ class Texture {
// Called on GPU thread.
virtual void MarkNewFrameAvailable() = 0;

// Called on GPU thread.
virtual void OnUnregistered() = 0;
Copy link
Member

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;
Copy link
Member

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;


~MockTexture() override = default;

bool unregistered = false;
Copy link
Member

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 {}
Copy link
Member

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|.

@cyanglaz
Copy link
Contributor Author

cyanglaz commented Oct 7, 2019

@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.
If you are ok with the new tests, please LGTM it. I'll wait for you to approve it before merging the PR.

@cyanglaz cyanglaz merged commit 0d59c9e into flutter:master Oct 8, 2019
@cyanglaz cyanglaz deleted the texture_race branch October 8, 2019 19:46
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Oct 8, 2019
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Oct 9, 2019
engine-flutter-autoroll added a commit to flutter/flutter that referenced this pull request Oct 9, 2019
git@github.com:flutter/engine.git/compare/c635d70c7266...21b8224

git log c635d70..21b8224 --no-merges --oneline
2019-10-08 gspencergoog@users.noreply.github.com Send AccessibilityEvent.TYPE_VIEW_FOCUSED when input focus is set. (flutter/engine#12746)
2019-10-08 dnfield@google.com Fix for a11y crash on iOS (flutter/engine#12990)
2019-10-08 katelovett@google.com Link Semantics Typo (flutter/engine#13009)
2019-10-08 ferhat@gmail.com [web] Add support for path transform (flutter/engine#12794)
2019-10-08 jason-simmons@users.noreply.github.com Auto-formatter fixes for BUILD.gn files (flutter/engine#13005)
2019-10-08 bkonyi@google.com Unblock SIGPROF on flutter_tester start (flutter/engine#12813)
2019-10-08 mouad.debbar@gmail.com [web] Update the url when route is replaced (flutter/engine#13003)
2019-10-08 katelovett@google.com Missing link flag (flutter/engine#13001)
2019-10-08 30870216+gaaclarke@users.noreply.github.com Started setting our debug background task id to invalid after completion. (flutter/engine#12999)
2019-10-08 ychris@google.com 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 chinmaygarde@google.com 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
Inconnu08 pushed a commit to Inconnu08/flutter that referenced this pull request Nov 26, 2019
git@github.com:flutter/engine.git/compare/c635d70c7266...21b8224

git log c635d70..21b8224 --no-merges --oneline
2019-10-08 gspencergoog@users.noreply.github.com Send AccessibilityEvent.TYPE_VIEW_FOCUSED when input focus is set. (flutter/engine#12746)
2019-10-08 dnfield@google.com Fix for a11y crash on iOS (flutter/engine#12990)
2019-10-08 katelovett@google.com Link Semantics Typo (flutter/engine#13009)
2019-10-08 ferhat@gmail.com [web] Add support for path transform (flutter/engine#12794)
2019-10-08 jason-simmons@users.noreply.github.com Auto-formatter fixes for BUILD.gn files (flutter/engine#13005)
2019-10-08 bkonyi@google.com Unblock SIGPROF on flutter_tester start (flutter/engine#12813)
2019-10-08 mouad.debbar@gmail.com [web] Update the url when route is replaced (flutter/engine#13003)
2019-10-08 katelovett@google.com Missing link flag (flutter/engine#13001)
2019-10-08 30870216+gaaclarke@users.noreply.github.com Started setting our debug background task id to invalid after completion. (flutter/engine#12999)
2019-10-08 ychris@google.com 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 chinmaygarde@google.com 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
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants