Repository navigation
Android: Fixed keyboard switcher immediately closing after it opens on the Google Pixel 10. - #97
Merged
Merged
Conversation
…n the Google Pixel 10. Root cause: the bug is in the Android System WebView (156.0.8078.47), not in Vector's own code (Chromium issue crbug.com/560321831). This WebView version hides the keyboard whenever the app's window loses focus. Gboard's keyboard switcher takes that focus when it opens, so the keyboard was hidden and the switcher closed straight away. A debugger stack trace showed the hide coming from WebView's own input code. Chromium has since changed this to stop hiding the keyboard. Fix (MainActivity.kt): the WebView now sits inside a small wrapper. While the keyboard is showing, the wrapper doesn't pass a focus-loss signal on to the WebView. If the app is actually being left, the held signal is passed on in onPause. Expected to be unaffected: • Other keyboards (Samsung, SwiftKey, older Gboard): they just get the same fix if their switcher steals focus. If they don't, nothing changes. • Older WebView versions, or future ones with Chromium's fix: holding back the focus loss only skips a keyboard reset that isn't needed there. • Older Android versions: if the keyboard-visible check misreads on an older device, the code falls back to the old behaviour. • Read receipts and the window-active state: Tauri gets focus changes from the activity directly, not through the view tree, so these still work. • Layout, side-edge gestures and Mini App overlays: the wrapper fills the screen, and no Vector code or bundled Tauri plugin assumes the WebView is the top-level view. Small behaviour changes: • Notification shade or a system dialog opened while typing: the keyboard now stays up behind it, as it does in native apps. The page also no longer gets a blur event at that moment, so a tooltip or context menu may stay open until you return. Leaving the app still hands the WebView the focus loss. • Split-screen or freeform windows (foldables, tablets): if focus moves to the other app while Vector's keyboard is up, Vector isn't paused, so the WebView keeps acting focused (for example, a blinking cursor) until you return. This is cosmetic. Known gap: Mini App WebViews aren't wrapped, so the keyboard switcher may still close inside Mini Apps on affected WebView versions. I can wrap them the same way if you want.
|
Tested and confirmed this fix using the specified WebView versions installed on an emulator, massively appreciate the PR, you will be included in the Vector v0.5.0 Release Notes. 🙏 💚 @th2tran |
|
Appreciate the in-depth issue report with source/videos, @th2tran. Ideal report & resolve ✅ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Root cause:
the bug is in the Android System WebView (156.0.8078.47), not in Vector's own code (Chromium issue crbug.com/560321831). This WebView version hides the keyboard whenever the app's window loses focus. Gboard's keyboard switcher takes that focus when it opens, so the keyboard was hidden and the switcher closed straight away. A debugger stack trace showed the hide coming from WebView's own input code. Chromium has since changed this to stop hiding the keyboard.
Fix (MainActivity.kt):
the WebView now sits inside a small wrapper. While the keyboard is showing, the wrapper doesn't pass a focus-loss signal on to the WebView. If the app is actually being left, the held signal is passed on in onPause.
Expected to be unaffected:
• Other keyboards (Samsung, SwiftKey, older Gboard): they just get the same fix if their switcher steals focus. If they don't, nothing changes.
• Older WebView versions, or future ones with Chromium's fix: holding back the focus loss only skips a keyboard reset that isn't needed there.
• Older Android versions: if the keyboard-visible check misreads on an older device, the code falls back to the old behaviour.
• Read receipts and the window-active state: Tauri gets focus changes from the activity directly, not through the view tree, so these still work.
• Layout, side-edge gestures and Mini App overlays: the wrapper fills the screen, and no Vector code or bundled Tauri plugin assumes the WebView is the top-level view.
Small behaviour changes:
• Notification shade or a system dialog opened while typing: the keyboard now stays up behind it, as it does in native apps. The page also no longer gets a blur event at that moment, so a tooltip or context menu may stay open until you return. Leaving the app still hands the WebView the focus loss.
• Split-screen or freeform windows (foldables, tablets): if focus moves to the other app while Vector's keyboard is up, Vector isn't paused, so the WebView keeps acting focused (for example, a blinking cursor) until you return. This is cosmetic.
Known gap: Mini App WebViews aren't wrapped, so the keyboard switcher may still close inside Mini Apps on affected WebView versions. I can wrap them the same way if you want.
Video recording of bug behaviour:
https://github.com/user-attachments/assets/39813ad0-b858-4e99-8024-e07d8e8d2e18
Video recording of bug fix:
https://github.com/user-attachments/assets/ae020c89-86e0-4db6-b85b-0fd1654354ca