Skip to content
This repository has been archived by the owner on Feb 22, 2023. It is now read-only.

[webview_flutter_android] Adds support for use of old hybrid composition #6063

Merged
merged 8 commits into from
Jul 20, 2022

Conversation

bparrishMines
Copy link
Contributor

@bparrishMines bparrishMines commented Jun 30, 2022

Adds support for Hybrid Composition to deal with: flutter/flutter#104686
Also fixes: flutter/flutter#102284

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 relevant style guides and ran the auto-formatter. (Unlike the flutter/flutter repo, the flutter/plugins repo does use dart format.)
  • I signed the CLA.
  • The title of the PR starts with the name of the plugin surrounded by square brackets, e.g. [shared_preferences]
  • I listed at least one issue that this PR fixes in the description above.
  • I updated pubspec.yaml with an appropriate new version according to the pub versioning philosophy, or this PR is exempt from version changes.
  • I updated CHANGELOG.md to add a description of the change, following repository CHANGELOG style.
  • 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.

If you need help, consider asking for advice on the #hackers-new channel on Discord.

@github-actions github-actions bot added p: webview_flutter Edits files for a webview_flutter plugin platform-android labels Jun 30, 2022
/// Android. It solves multiple issues related to accessibility and interaction
/// with the [WebView] at the cost of some performance on Android versions below
/// 10. See https://github.com/flutter/flutter/wiki/Hybrid-Composition for more
/// information.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is no longer true for this AndroidView. I moved it to the new one.

Copy link
Contributor

Choose a reason for hiding this comment

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

I believe the parts about accessibility and interaction are still true, relative to VD?

We should document the known tradeoffs of this relative to the other two here. We should also add that to the README for this package, and/or some Flutter docs page somewhere (and then later we can link to that from the main README).

@@ -59,7 +53,8 @@ class SurfaceAndroidWebView extends AndroidWebView {
// WebView content is not affected by the Android view's layout direction,
// we explicitly set it here so that the widget doesn't require an ambient
// directionality.
layoutDirection: TextDirection.rtl,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This shouldn't be a breaking change for large majority of people. This value is ignored unless support for this is explicitly added to the AndroidManifest.xml. For example, it is still ltr in our example app.

@bparrishMines bparrishMines changed the title Android render [webview_flutter_android] Adds support for use of old hybrid composition Jun 30, 2022

environment:
sdk: ">=2.14.0 <3.0.0"
flutter: ">=2.8.0"
flutter: ">=3.0.0"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Required for initExpensiveAndroidView

/// To use this, set [WebView.platform] to an instance of this class.
///
/// This implementation uses hybrid composition to render the [WebView] on
/// Android. It solves multiple issues related to accessibility and interaction
Copy link
Contributor

Choose a reason for hiding this comment

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

Now that we have three options, we need to be clear in each one what we are comparing against. E.g., my understanding is that the new mode (I'm just going to call it Mode3 until we pick a name 🙂 ) doesn't have accessibility issues, and that that's specific to the old VirtualDisplay implementation.

The advantage of this one vs. SurfaceAndroidWebView AFAIK is transparency support on older versions of Android. Are there other know issue with Mode3 relative to HC?

/// Android. It solves multiple issues related to accessibility and interaction
/// with the [WebView] at the cost of some performance on Android versions below
/// 10. See https://github.com/flutter/flutter/wiki/Hybrid-Composition for more
/// information.
Copy link
Contributor

Choose a reason for hiding this comment

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

I believe the parts about accessibility and interaction are still true, relative to VD?

We should document the known tradeoffs of this relative to the other two here. We should also add that to the README for this package, and/or some Flutter docs page somewhere (and then later we can link to that from the main README).

@bparrishMines
Copy link
Contributor Author

@stuartmorgan This is ready for another review.

I switched the implementation to use the expensive android view when the background color is set as transparent. Since background color is a creation param, changes to it are ignored after the webview is already built.

Copy link
Contributor

@stuartmorgan stuartmorgan left a comment

Choose a reason for hiding this comment

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

Looks like this is breaking tests on the API 26 device? But otherwise LG.

(Based on the findings I wrote up in flutter/flutter#107313 we have other problems with webview that I hadn't realized before, but this change will still be an incremental improvement.)

@bparrishMines
Copy link
Contributor Author

@stuartmorgan I reran the test and it passed. I believe it was just a timeout. If you believe this is good, could you approve the PR?

Copy link
Contributor

@stuartmorgan stuartmorgan left a comment

Choose a reason for hiding this comment

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

LGTM

yutaaraki-toydium added a commit to yutaaraki-toydium/plugins that referenced this pull request Aug 12, 2022
mauricioluz pushed a commit to mauricioluz/plugins that referenced this pull request Jan 26, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
autosubmit Merge PR when tree becomes green via auto submit App p: webview_flutter Edits files for a webview_flutter plugin platform-android
Projects
None yet
Development

Successfully merging this pull request may close these issues.

The webview_flutter scroll bar appears on the left
2 participants