Fix pinch-to-zoom remaining active when page zoom is set#6896
Conversation
|
Thanks for the fix! Do you have a good way to reproduce the issue so we can validate it?
Could you submit this separately? It may be required for this PR but we can review it standalone. |
f6f0a60 to
d3146d1
Compare
@jpelgrom I couldn't reproduce it until I reinstalled the app (clearing data didn't work), not sure why is that. Below is the screen recording reproducing this bug: out.mp4
Sure, I've moved it to another PR: #6902 |
| @@ -136,7 +144,10 @@ sealed interface WebViewAction { | |||
| override fun run(webView: WebView) { | |||
There was a problem hiding this comment.
That's my fault but we misses some unit tests on the WebViewActions can you at least add the one for the ApplyZoom action? It should verify that we call the right settings with the right value and help us avoid making unwanted mistake in the future.
There was a problem hiding this comment.
@TimoPtr thanks for your work! Sure, I've added two tests
0a975b9 to
439ca3e
Compare
|
|
||
| verify { webView.settings.setSupportZoom(true) } | ||
| verify { webView.settings.builtInZoomControls = true } | ||
| assertTrue(scriptSlot.captured.contains("user-scalable=yes")) |
There was a problem hiding this comment.
This isn't a good test, because the script will always contain user-scalable=yes and only once it's evaluated will it actually run the script and decide which branch to use. You can copy this line and add it to the test with pinchToZoomEnabled false, copy the scriptSlot line from that test to this one, and both tests will still pass.
Summary
When "Page zoom" is set to anything other than the default 100%, the webview still accepts pinch gestures to zoom with a small range around the configured initial scale, even when "Pinch-to-zoom" is disabled.
The root cause is toggling
WebSettings.builtInZoomControlsalone is not enough to disable pinch when a customsetInitialScaleis applied, this fix togglesWebSettings.setSupportZoomtogether so that disabling pinch-to-zoom fully disables it regardless of the configured page zoom.After this fix, I noticed that toggling pinch-to-zoom only took effect after changing the page zoom. I found it's because in
LocalStorageImpl.observeChanges,awaitClosewas placed inside thekeys.forEachloop, the coroutine suspended after the first iteration, so the listeners for the remaining keys were never registered. The first key was effectively the only one observed, changes to later keys are ignored silently.I have opened another PR for that fix: #6902
Checklist
Any other notes
Depends on #6902 to be merged to work properly.