Skip to content

Conversation

@stuartmorgan-g
Copy link
Contributor

@stuartmorgan-g stuartmorgan-g commented Aug 8, 2022

Allows for the new Android platform view mode introduced in Flutter 3.0 (tentatively called Texture Layer Hybrid Composition) to fall back to Hybrid Composition rather than Virtual Display when TLHC mode is not supported if it was created with initSurfaceAndroidView, which was HC in Flutter 2.x. This allows us to avoid the issue introduced in Flutter 3.0 where a plugin that previously used HC will now use VD in some cases, which would not be the plugin author's intent since they had explicitly chosen the initialization mode that was for HC in Flutter 2.x.

In order to minimize breaking changes (in the hopes of cherry picking this to beta), this keeps all of the existing class return types, and extracts all of their logic to display-specific helpers that can be delegated to, allowing for the same class to switch from TLHC (which uses texture display) to HC (which composes actual views).

Fixes #107313
Engine portion: flutter/engine#35233

Pre-launch Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I read and followed the Flutter Style Guide, including Features we expect every widget to implement.
  • I signed the CLA.
  • I listed at least one issue that this PR fixes in the description above.
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making, or this PR is test-exempt.
  • All existing and new tests are passing.

@flutter-dashboard
Copy link

It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact Hixie on the #hackers channel in Chat (don't just cc him here, he won't see it! He's on Discord!).

If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix?

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.

@flutter-dashboard flutter-dashboard bot added the framework flutter/packages/flutter repository. See also f: labels. label Aug 8, 2022
@stuartmorgan-g
Copy link
Contributor Author

@bparrishMines @dnfield Same here; still needs tests, but I would appreciate feedback.

I have concerns about the fundamentals of the create/resize logic code here for TLHC (i.e., I suspect there are more subtle race conditions that are still latent here that this change neither fixes nor worsens), but wanted to limit the scope here since I am still hoping to get this onto beta.

@stuartmorgan-g
Copy link
Contributor Author

This also fixes a 3.0 regression found during manual testing, where create is sometimes called multiple times: once by the plugin author, but then again by internal code that was only intended to be used for TLHC and VD, but due to the async nature of the initialization, was being called for HC as well. Because some plugin authors have noticed the double-call bug and worked around it by removing their create, we can't actually directly fix the double-create without more extensive changes (unless we re-break plugins that worked around the 3.0 bug), so for now this drops duplicate calls, and leaves TODOs for fixing it more cleanly.

With more investigation, it looks like this is actually a 3.1+ regression, so I'm going to split it out into its own fix. It's a new regression that only affects beta, and it severely breaks HC mode, so should be fixed and cherry-picked separately. (I was hoping to avoid layer fixes and cherry picks, but this seems critical enough to take that risk.)

@stuartmorgan-g stuartmorgan-g marked this pull request as ready for review August 12, 2022 18:15
@stuartmorgan-g
Copy link
Contributor Author

This still needs widgets tests for the new switching widget, but I think it would be worth reviewing now to see if that approach is in fact what we want before I implement the tests for it.

Copy link
Contributor

@bparrishMines bparrishMines left a comment

Choose a reason for hiding this comment

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

LGTM Someone on the framework team should should probably have a look as well though. I'm not sure who currently own this code

Copy link
Contributor

@dnfield dnfield left a comment

Choose a reason for hiding this comment

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

LGTM

@orestesgaolin
Copy link
Contributor

orestesgaolin commented Aug 21, 2022

I have a small question. After this gets merged what would be the breakdown of modes?

  • initSurfaceAndroidView -> TLHC, but can fallback to HC when SDK <23
  • initAndroidView -> TLHC, but fallback to VD when SDK <23
  • initExpensiveAndroidView -> always TLHC (?)

What would be used by default by AndroidView?

@stuartmorgan-g
Copy link
Contributor Author

  • initExpensiveAndroidView -> always TLHC (?)

This PR doesn't change the behavior of initExpensiveAndroidView. It continues to always use HC.

What would be used by default by AndroidView?

This PR doesn't change the behavior of AndroidView, which calls initAndroidView.

@goderbauer
Copy link
Member

(triage): @stuartmorgan do you still have plans for this PR?

@stuartmorgan-g
Copy link
Contributor Author

I'll be updating it shortly to be landing-ready; the engine side just landed.

@stuartmorgan-g stuartmorgan-g added the autosubmit Merge PR when tree becomes green via auto submit App label Sep 21, 2022
@auto-submit auto-submit bot merged commit bc994c7 into flutter:master Sep 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

autosubmit Merge PR when tree becomes green via auto submit App framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

initSurfaceAndroidView uses Virtual Display as fallback mode

5 participants