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

Hand off presentation properly in VirtualDisplayController.resize()#17897

Merged
GaryQian merged 4 commits into
flutter-team-archive:masterfrom
GaryQian:videocrash
Apr 23, 2020
Merged

Hand off presentation properly in VirtualDisplayController.resize()#17897
GaryQian merged 4 commits into
flutter-team-archive:masterfrom
GaryQian:videocrash

Conversation

@GaryQian

@GaryQian GaryQian commented Apr 23, 2020

Copy link
Copy Markdown
Contributor

Based off of #17611 by @dotcink

Fixes flutter/flutter#26345 and flutter/flutter#47154

Previously, we were overwriting the presentation variable with an instance of a new SingleViewPresentation. This caused the old one to remain in memory and crash when callbacks were triggered before GC

This patch creates the new SingleViewPresentation without overwriting the old presentation, shows the new one to maintain smooth transition (without this ordering of calls, content like videos stop playing) and then when the old presentation is no longer needed, calls cancel() and sets the reference to the new presentation.

@GaryQian GaryQian changed the title Handoff presentation properly in VirtualDisplatController.resize() Hand off presentation properly in VirtualDisplatController.resize() Apr 23, 2020
@GaryQian GaryQian requested a review from cyanglaz April 23, 2020 08:56
@GaryQian GaryQian changed the title Hand off presentation properly in VirtualDisplatController.resize() Hand off presentation properly in VirtualDisplayController.resize() Apr 23, 2020

@amirh amirh left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM (though would love a clarification on my comment below)

presentation =
// Initialize a new presentation. We don't want to cancel
// the old one before we can properly show the new one to
// take over where it left off.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure I understand this comment, what side effect does newPresentation.show() has that makes presentation.cancel() safer?

// Initialize a new presentation. We don't want to cancel
// the old one before we can properly show the new one to
// take over where it left off. Cancelling before the show()
// of the new presentation causes the contents to stop, eg,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm still confused by this, the view is detached from the presentation at the point we are cancelling it, not sure why would it cause a video to stop or why would showing a different presentation with that view will prevent the video from stopping?

Do you happen to which methods are invoked on the view in which order in the two scenarios? (the one where it stops and the one where it continue playing?)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So I don't think I know enough about the inner workings of this to write a fully descriptive comment here. Most of this is from what I have gleaned via experimentation getting this to work. My comments here are mainly trying to explain the ordering that needs to happen, but I'm not 100% clear on specifically what in the implementations makes this necessary other that other orderings do not work. I don't want to pick out anything too specific as it may pin the cause incorrectly.

Any suggestions?

@GaryQian

Copy link
Copy Markdown
Contributor Author

cc @chinmaygarde

@amirh

amirh commented Apr 23, 2020 via email

Copy link
Copy Markdown
Contributor

@GaryQian GaryQian merged commit 0273fab into flutter-team-archive:master Apr 23, 2020
// PlatformViewsController. We know that all PlatformViewsController does is
// forward view attachment/detachment calls to it's VirtualDisplayControllers.
//
// TODO(mattcarroll): once PlatformViewsController is refactored into testable

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fwiw, I don't think Matt will be doing this refactor :)

engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Apr 24, 2020
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Apr 24, 2020
pcsosinski pushed a commit that referenced this pull request May 12, 2020
* Update 1.17 engine hash to Dart 2.8.2 stable

* Hand off presentation properly in VirtualDisplayController.resize() (#17897)

Co-authored-by: Gary Qian <garyq@google.com>
cg021 pushed a commit to cg021/engine that referenced this pull request Jun 1, 2020
* Update 1.17 engine hash to Dart 2.8.2 stable

* Hand off presentation properly in VirtualDisplayController.resize() (flutter-team-archive#17897)

Co-authored-by: Gary Qian <garyq@google.com>
RRDJ pushed a commit to RRDJ/engine-rr that referenced this pull request Jun 2, 2020
* Update 1.17 engine hash to Dart 2.8.2 stable

* Hand off presentation properly in VirtualDisplayController.resize() (flutter-team-archive#17897)

Co-authored-by: Gary Qian <garyq@google.com>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Development

Successfully merging this pull request may close these issues.

Updating AndroidView layer tree cause 100% crash on some brand device

4 participants