Skip to content

[webview_flutter_android] feat: Expose setUseWideViewPort on Android (#106999) #9151

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 14 commits into from
May 16, 2025

Conversation

Gustl22
Copy link
Contributor

@Gustl22 Gustl22 commented Apr 25, 2025

The option to set whether the webview should use the wide viewport should be available.
Also the default is changed to false, because this is the expected behavior on Android devices:
https://developer.android.com/develop/ui/views/layout/webapps/targeting
On iOS also the default behavior is to NOT use wide viewport, so this is aligned.

Note: When your page is rendered in a WebView, it doesn't use wide viewport mode by default. You can enable wide viewport mode with setUseWideViewPort().

This also partically solves flutter/flutter#106999, as then the correct height is returned from document.documentElement.scrollHeight; property.

If you had to change anything in the flutter/tests repo, include a link to the migration guide as per the breaking change policy.

Pre-launch Checklist

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

@Gustl22 Gustl22 requested a review from bparrishMines as a code owner April 25, 2025 14:08
@Gustl22 Gustl22 changed the title 106999 webview expose wide screen feat: Expose setUseWideViewPort on Android (#106999) Apr 25, 2025
@stuartmorgan-g
Copy link
Contributor

Also the default is changed to false, because this is the expected behavior on Android devices

This may break some people; see flutter/flutter#93125 for example.

@Gustl22
Copy link
Contributor Author

Gustl22 commented Apr 30, 2025

Thank you for the intels.

This may break some people; see flutter/flutter#93125 for example.

That's true, what exactly should be the next steps? I also tried to reproduce your linked issue, but couldn't as the linked site was reworked and doesn't show this problem any more.

  1. Use true as default for setUseWideViewPort
  • would ensure that nothing breaks due to keeping the current default
  • may leads to annoyance as package users expect the same behavior on Android and iOS
  1. Use false as default for setUseWideViewPort
  • Making a breaking change and write a migration guide
  • probably very few care as the behavior was different on Android and iOS and noone noticed
  • Nontheless could lead to unexpected outcome for certain products, when using flutter specifically on only one platform
  • WebViews are hard to test so the behavior should be aligned in both platforms to not challenge more differences across both platforms
  • Raise a major version for webview package
  • Aligns with native Android and Flutter iOS implementation
Webkit / iOS Android setUseWideViewPort(true) Android setUseWideViewPort(false)

@stuartmorgan-g
Copy link
Contributor

  • probably very few care as the behavior was different on Android and iOS and noone noticed
  • WebViews are hard to test so the behavior should be aligned in both platforms to not challenge more differences across both platforms

I think these are good arguments for switching the default back. And clients will have the escape hatch of the new setting if they really need the other behavior. Thanks for the analysis!

Since the initial change wasn't a major version change, and as you point out this is likely not going to affect most clients, we don't need to do a major version change to switch it back IMO.

@Gustl22
Copy link
Contributor Author

Gustl22 commented May 8, 2025

Thank you for the fast reply.

Should I leave the viewport meta example in the example project? Or is it also desired to be adapted in the webview_flutter_android example project? Do example project updates need version changes?

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.

@Gustl22 The example apps are mostly used for maintainers to test things manually. Since this flag is unique to Android, I think you should move the changes you made in webview_flutter example to webview_flutter_android example.

@Gustl22
Copy link
Contributor Author

Gustl22 commented May 14, 2025

@bparrishMines Thank you for the review. I moved the example to the android project, although I think it is good to have it in the main project to be able to compare the behavior with ios (as there is no such setting). But it might doesn't matter much in the end. Also tweaked the changelog a bit.

@Gustl22 Gustl22 requested a review from bparrishMines May 14, 2025 10:05
@Gustl22 Gustl22 changed the title feat: Expose setUseWideViewPort on Android (#106999) [webview_flutter_android] feat: Expose setUseWideViewPort on Android (#106999) May 14, 2025
Gustl22 added 2 commits May 15, 2025 15:21
…se-wide-screen

# Conflicts:
#	packages/webview_flutter/webview_flutter_android/CHANGELOG.md
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

@stuartmorgan-g for secondary review

Copy link
Contributor

@stuartmorgan-g stuartmorgan-g left a comment

Choose a reason for hiding this comment

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

LGTM

@stuartmorgan-g stuartmorgan-g added the autosubmit Merge PR when tree becomes green via auto submit App label May 16, 2025
@auto-submit auto-submit bot merged commit 58d4016 into flutter:main May 16, 2025
82 checks passed
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request May 16, 2025
github-merge-queue bot pushed a commit to flutter/flutter that referenced this pull request May 16, 2025
flutter/packages@2dff621...58d4016

2025-05-16 [email protected] [webview_flutter_android]
feat: Expose setUseWideViewPort on Android (#106999)
(flutter/packages#9151)
2025-05-15 [email protected] Roll Flutter from
0b9f928 to 9a78af5 (26 revisions) (flutter/packages#9259)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages-flutter-autoroll
Please CC [email protected] on the revert to ensure that a
human
is aware of the problem.

To file a bug in Flutter:
https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
FMorschel pushed a commit to FMorschel/packages that referenced this pull request Jun 9, 2025
…(#106999) (flutter#9151)

The option to set whether the webview should use the wide viewport should be available.
Also the default is changed to false, because this is the expected behavior on Android devices:
https://developer.android.com/develop/ui/views/layout/webapps/targeting
On iOS also the default behavior is to NOT use wide viewport, so this is aligned.

> Note: When your page is rendered in a WebView, it doesn't use wide viewport mode by default. You can enable wide viewport mode with setUseWideViewPort().

This also partically solves flutter/flutter#106999, as then the correct height is returned from `document.documentElement.scrollHeight;` property.

*If you had to change anything in the [flutter/tests] repo, include a link to the migration guide as per the [breaking change policy].*
Ortes pushed a commit to Ortes/packages that referenced this pull request Jun 25, 2025
…(#106999) (flutter#9151)

The option to set whether the webview should use the wide viewport should be available.
Also the default is changed to false, because this is the expected behavior on Android devices:
https://developer.android.com/develop/ui/views/layout/webapps/targeting
On iOS also the default behavior is to NOT use wide viewport, so this is aligned.

> Note: When your page is rendered in a WebView, it doesn't use wide viewport mode by default. You can enable wide viewport mode with setUseWideViewPort().

This also partically solves flutter/flutter#106999, as then the correct height is returned from `document.documentElement.scrollHeight;` property.

*If you had to change anything in the [flutter/tests] repo, include a link to the migration guide as per the [breaking change policy].*
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 p: webview_flutter platform-android
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants