Skip to content
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

[webview_flutter] Input needs to be tapped twice to be registered on Samsung devices #35867

Closed
luckmlc opened this issue Jul 10, 2019 · 21 comments · Fixed by flutter/plugins#1965
Assignees
Labels
a: platform-views Embedding Android/iOS views in Flutter apps e: device-specific Only manifests on certain devices p: webview The WebView plugin package flutter/packages repository. See also p: labels. platform-android Android applications specifically
Milestone

Comments

@luckmlc
Copy link

luckmlc commented Jul 10, 2019

Edit by @mklim: Comment-511798199 found the Samsung issue. The first few comments in the chain refer to earlier versions of Flutter without any keyboard support at all. Quoting the relevant comment below.

Maybe Samsung mobile phones have this problem,I tried two Samsung phones.
samsung galaxy s6 edge+
samsung galaxy S7(G9300)

The problem may be that it won't get the focus for the first time , you need to click the input box again.

Please see the gif below:

gifhome_320x564_15s

flutter: Channel master, v1.8.2-pre.42
webview_flutter: ^0.3.10+2

My environment is as follows:

/Users/mayer/development/flutter/bin/flutter doctor --verbose
[✓] Flutter (Channel master, v1.8.2-pre.42, on Mac OS X 10.14.4 18E226, locale zh-Hans-CN)
    • Flutter version 1.8.2-pre.42 at /Users/mayer/development/flutter
    • Framework revision 35b07a1f7f (8 hours ago), 2019-07-15 23:43:27 -0400
    • Engine revision 74af88ba9f
    • Dart version 2.5.0 (build 2.5.0-dev.1.0 24725a8559)

[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
    • Android SDK at /Users/mayer/Library/Android/sdk
    • Android NDK location not configured (optional; useful for native profiling support)
    • Platform android-28, build-tools 28.0.3
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1343-b01)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 10.2.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 10.2.1, Build version 10E1001
    • CocoaPods version 1.6.1

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 3.4)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin version 37.0.1
    • Dart plugin version 183.6270
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1343-b01)

[✓] Connected device (3 available)
    • SM G9280 • 0815f8acd00f1b04 • android-arm64  • Android 7.0 (API 24)
    • macOS    • macOS            • darwin-x64     • Mac OS X 10.14.4 18E226
    • Chrome   • chrome           • web-javascript • Google Chrome 75.0.3770.142 


• No issues found!
Process finished with exit code 0

Run the example in the webview_flutter plugin.
When I typed on the pop-up keyboard, the text I entered was not displayed.

Please see the gif below:

image

flutter 1.7.8
webview_flutter 0.3.9+1

My environment is as follows:

/Users/mayer/development/flutter/bin/flutter doctor --verbose
[✓] Flutter (Channel stable, v1.7.8+hotfix.3, on Mac OS X 10.14.4 18E226, locale zh-Hans-CN)
    • Flutter version 1.7.8+hotfix.3 at /Users/mayer/development/flutter
    • Framework revision b712a172f9 (15 hours ago), 2019-07-09 13:14:38 -0700
    • Engine revision 54ad777fd2
    • Dart version 2.4.0

[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
    • Android SDK at /Users/mayer/Library/Android/sdk
    • Android NDK location not configured (optional; useful for native profiling support)
    • Platform android-28, build-tools 28.0.3
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1343-b01)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 10.2.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 10.2.1, Build version 10E1001
    • CocoaPods version 1.6.1

[✓] iOS tools - develop for iOS devices
    • ios-deploy 1.9.4

[✓] Android Studio (version 3.4)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin version 35.3.1
    • Dart plugin version 183.6270
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1343-b01)

[✓] Connected device (1 available)
    • SM G9280 • 0815f8acd00f1b04 • android-arm64 • Android 7.0 (API 24)

• No issues found!
Process finished with exit code 0
@Jiyupeng334
Copy link

I have same question.This problem arises because I need to new a webview to open new window for logining facebook.My flutter version is 1.7.11.

@kangwang1988 kangwang1988 pinned this issue Jul 15, 2019
@kangwang1988 kangwang1988 unpinned this issue Jul 15, 2019
@kangwang1988
Copy link
Contributor

kangwang1988 commented Jul 15, 2019

@jyp334 @luckmlc
Have you tried the latest master branch for flutter & webview_flutter.
It works fine using the latest master branch.

Untitled

flutter doctor -v

(base) kylewong@KyleWongs-MacBook-Pro example % flutter doctor -v
[!] Flutter (Channel master, v1.8.2-pre.33, on Mac OS X 10.15 19A501i, locale en-CN)
    • Flutter version 1.8.2-pre.33 at /Users/kylewong/Codes/Flutter/flutter
    • Framework revision e3ee5c6bbb (2 days ago), 2019-07-13 16:02:09 -0700
    • Engine revision 919e353236
    • Dart version 2.5.0 (build 2.5.0-dev.1.0 24725a8559)
    ✗ Downloaded executables cannot execute on host.
      See https://github.com/flutter/flutter/issues/6207 for more information


 
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.0)
    • Android SDK at /Users/kylewong/Library/Android/sdk
    • Android NDK location not configured (optional; useful for native profiling support)
    • Platform android-29, build-tools 29.0.0
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1343-b01)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 11.0)
    • Xcode at /Applications/Xcode-beta.app/Contents/Developer
    • Xcode 11.0, Build version 11M337n
    • CocoaPods version 1.7.3

[!] iOS tools - develop for iOS devices
    ✗ Verify that all connected devices have been paired with this computer in Xcode.
      If all devices have been paired, libimobiledevice and ideviceinstaller may require updating.
      To update with Brew, run:
        brew update
        brew uninstall --ignore-dependencies libimobiledevice
        brew uninstall --ignore-dependencies usbmuxd
        brew install --HEAD usbmuxd
        brew unlink usbmuxd
        brew link usbmuxd
        brew install --HEAD libimobiledevice
        brew install ideviceinstaller
    • ios-deploy 1.9.4

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 3.4)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin version 36.1.1
    • Dart plugin version 183.6270
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1343-b01)

[✓] VS Code (version 1.36.0)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.2.0

[✓] Connected device (3 available)
    • PBCT10 • 80790da • android-arm64  • Android 8.1.0 (API 27)

git@github.com:flutter/plugins.git is at commit: 518c8f0

@kangwang1988 kangwang1988 added the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Jul 15, 2019
@luckmlc
Copy link
Author

luckmlc commented Jul 16, 2019

@kangwang1988

I switched the Master version and the text entered still doesn't display.

/Users/mayer/development/flutter/bin/flutter doctor --verbose
[✓] Flutter (Channel master, v1.8.2-pre.41, on Mac OS X 10.14.4 18E226, locale zh-Hans-CN)
    • Flutter version 1.8.2-pre.41 at /Users/mayer/development/flutter
    • Framework revision 2d08fec368 (2 hours ago), 2019-07-15 18:31:44 -0700
    • Engine revision 3f27c5724c
    • Dart version 2.5.0 (build 2.5.0-dev.1.0 24725a8559)

[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
    • Android SDK at /Users/mayer/Library/Android/sdk
    • Android NDK location not configured (optional; useful for native profiling support)
    • Platform android-28, build-tools 28.0.3
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1343-b01)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 10.2.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 10.2.1, Build version 10E1001
    • CocoaPods version 1.6.1

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 3.4)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin version 35.3.1
    • Dart plugin version 183.6270
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1343-b01)

@no-response no-response bot removed the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Jul 16, 2019
@kangwang1988
Copy link
Contributor

@luckmlc
Please make sure that both flutter&webview_flutter is at the latest master.
Besides, please check if it occurs on specific android device or every android devices you can get.
It might be device related.

@kangwang1988 kangwang1988 added the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Jul 16, 2019
@luckmlc
Copy link
Author

luckmlc commented Jul 16, 2019

@kangwang1988

Maybe Samsung mobile phones have this problem,I tried two Samsung phones.
samsung galaxy s6 edge+
samsung galaxy S7(G9300)

The problem may be that it won't get the focus for the first time , you need to click the input box again.

Please see the gif below:

gifhome_320x564_15s

flutter: Channel master, v1.8.2-pre.42
webview_flutter: ^0.3.10+2

My environment is as follows:

/Users/mayer/development/flutter/bin/flutter doctor --verbose
[✓] Flutter (Channel master, v1.8.2-pre.42, on Mac OS X 10.14.4 18E226, locale zh-Hans-CN)
    • Flutter version 1.8.2-pre.42 at /Users/mayer/development/flutter
    • Framework revision 35b07a1f7f (8 hours ago), 2019-07-15 23:43:27 -0400
    • Engine revision 74af88ba9f
    • Dart version 2.5.0 (build 2.5.0-dev.1.0 24725a8559)

[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
    • Android SDK at /Users/mayer/Library/Android/sdk
    • Android NDK location not configured (optional; useful for native profiling support)
    • Platform android-28, build-tools 28.0.3
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1343-b01)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 10.2.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 10.2.1, Build version 10E1001
    • CocoaPods version 1.6.1

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 3.4)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin version 37.0.1
    • Dart plugin version 183.6270
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1343-b01)

[✓] Connected device (3 available)
    • SM G9280 • 0815f8acd00f1b04 • android-arm64  • Android 7.0 (API 24)
    • macOS    • macOS            • darwin-x64     • Mac OS X 10.14.4 18E226
    • Chrome   • chrome           • web-javascript • Google Chrome 75.0.3770.142 


• No issues found!
Process finished with exit code 0

@no-response no-response bot removed the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Jul 16, 2019
@luckmlc
Copy link
Author

luckmlc commented Jul 17, 2019

@luckmlc
Please make sure that both flutter&webview_flutter is at the latest master.
Besides, please check if it occurs on specific android device or every android devices you can get.
It might be device related.

Samsung mobile phones have this problem,huawei and meitu phones is ok!

@Jiyupeng334
Copy link

Jiyupeng334 commented Jul 17, 2019

@kangwang1988 Hi , I just want to create a new window to complete the login function of facebook . My flutter version is 1.7.11 dev , This is my code to create a new window,In this new webview, the pop-up box is unable to pop up or cannot enter characters after it pops up.
''

@Override
        public boolean onCreateWindow(WebView view, boolean isDialog,
                                      boolean isUserGesture, Message resultMsg) {
            Log.d(TAG, "onCreateWindow");
            mWebviewPop = new WebView(mContext);
            mWebviewPop.setVerticalScrollBarEnabled(false);
            mWebviewPop.setWebChromeClient(this);
            mWebviewPop.setWebViewClient(new FacebookWebviewClient());
            WebSettings settings = mWebviewPop.getSettings();
            settings.setDomStorageEnabled(true);
            settings.setJavaScriptEnabled(true);
            settings.setSupportMultipleWindows(true);
            settings.setJavaScriptCanOpenWindowsAutomatically(true);
            mWebviewPop.setFocusable(true);
            mWebviewPop.requestFocus(View.FOCUS_DOWN);
            mWebviewPop.requestFocusFromTouch();
            mWebviewPop.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,ViewGroup.LayoutParams.MATCH_PARENT));
            webView.addView(mWebviewPop);
            CookieManager cookieManager = CookieManager.getInstance();
            cookieManager.setAcceptCookie(true);
            WebView.WebViewTransport transport = (WebView.WebViewTransport) resultMsg.obj;
            transport.setWebView(mWebviewPop);
            resultMsg.sendToTarget();
            return true;
        }

''
I hope to improve the Webview_flutter plugin as soon as possible .Or if you have a good way to solve the multi-window problem in webview, you can give me some Suggestions.

@kangwang1988
Copy link
Contributor

@jyp334
Please provide a self-contained flutter demo project so I can do some digging.

@kangwang1988
Copy link
Contributor

@luckmlc
Gotcha.
I will do some checking with samsung device.

@mklim mklim added a: platform-views Embedding Android/iOS views in Flutter apps e: device-specific Only manifests on certain devices p: first party p: webview The WebView plugin platform-android Android applications specifically labels Jul 18, 2019
@mklim mklim changed the title #webview_flutter plugins# When I typed on the pop-up keyboard, the text I entered was not displayed. [webview_flutter] Input needs to be tapped twice to be registered on Samsung devices Jul 18, 2019
@mklim
Copy link
Contributor

mklim commented Jul 18, 2019

I can reproduce the issue with a Galaxy S6 and the latest version of Flutter and the plugin.

I haven't investigated in detail yet, but this looks exactly like the previous failure from when lock and unlocking were needed but not added yet. /cc @amirh

@mklim mklim added this to the Goals milestone Jul 18, 2019
@mklim
Copy link
Contributor

mklim commented Jul 18, 2019

@amirh and I looked into this a little offline.

The problem appears to be where we restart the input connection on unlock. On Samsung devices this resets the InputConnection to null instead of restarting it and getting the previous good connection like on non Samsung devices. Deleting the code block "fixes" the issue completely. However that restart is there to prevent another issue on non-Samsung devices where ViewRootImpl cancels text events with a noisyCancelling event due to no window focus log.

We don't have a good idea for a fix yet. Working theory is that hopefully we can figure out some other way to correctly set ViewRootImpl's state so it doesn't try to drop these events on non Samsung devices, and then we can get rid of the restart.

@mklim mklim self-assigned this Jul 23, 2019
@mklim mklim modified the milestones: Goals, Near-term Goals Jul 23, 2019
@mklim
Copy link
Contributor

mklim commented Jul 23, 2019

Investigated this more today. So far I've been unable to find any state that differs between Samsung and non Samsung devices here, or any alternative ways to correctly set the window state in non Samsung devices.

The flow goes like this:

  1. User taps into any text field.
  2. InputAwareWebView#onCreateInputConnection -> returns good inputConnection
  3. IAWV#lockInputConnection()
  4. IAWV#unlockInputConnection() calls InputMethodManager.restartInput(IAWV#containerView)
  5. IAWV#onCreateInputConnection. This returns null on Samsung, but the same original good input connection as 2 everywhere else.

At no point in any of these steps is there an obvious difference between Samsung and other phones' focus, windowFocus, rootView#focus, rootView#windowFocus, or any of the IMM getters.

I think I may be able to hack around this and put in some logic like "if we've just restarted and we're about to return null from onCreateInputConnection, that means we're in this obscure bug condition so return this last non-null thing that we've cached instead". But that's brittle and I'm wary of adding something extra like that on here without getting to the bottom of it.

@mklim mklim assigned mklim and unassigned mklim Jul 30, 2019
@mklim mklim modified the milestones: Near-term Goals, October 2019 Jul 31, 2019
@zhhal
Copy link

zhhal commented Aug 4, 2019

I have the same problem on huawei and MI devices only when I use Baidu input method, other input method works well.

@pedrosalesmiranda
Copy link

pedrosalesmiranda commented Aug 7, 2019

Same issue here but not just Samsung devices also MI
Connected device (1 available)
• Redmi Note 4 • 5TFAFYWGS475VKHQ • android-arm64 • Android 6.0 (API 23)
webview_flutter: 0.3.11

And after the keyboard does not hide after the input confirmation

@pedrosalesmiranda
Copy link

Similar issue on Samsung device. But first at first tap input gets focus but keyboard does not show up. On second tap keyboard shows up and input is displayed.

Android toolchain - develop for Android devices (Android SDK version 29.0.1)
• Android SDK at /home/psm/Android/Sdk
• Android NDK location not configured (optional; useful for native profiling support)
• Platform android-29, build-tools 29.0.1
• Java binary at: /home/psm/Installs/android-studio/jre/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1343-b16-5323222)
• All Android licenses accepted.

[✓] Android Studio (version 3.4)
• Android Studio at /home/psm/Installs/android-studio
• Flutter plugin version 37.1.1
• Dart plugin version 183.6270
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1343-b16-5323222)

[!] IntelliJ IDEA Ultimate Edition (version 2019.1)
• IntelliJ at /home/psm/Installs/idea-IU-191.7479.19
✗ Flutter plugin not installed; this adds Flutter specific functionality.
✗ Dart plugin not installed; this adds Dart specific functionality.
• For information about installing plugins, see
https://flutter.dev/intellij-setup/#installing-the-plugins

[✓] Connected device (1 available)
• SM G950F • 988a5733564c304e4d • android-arm64 • Android 9 (API 28)

@pedrosalesmiranda
Copy link

@mklim tried webview_flutter on
• Redmi Note 4 • 5TFAFYWGS475VKHQ • android-arm64 • Android 6.0 (API 23)
webview_flutter: 0.3.11+2

issues is not solved. Nothing changed.

@mklim
Copy link
Contributor

mklim commented Aug 12, 2019

@pedrosalesmiranda thanks for the report. Just to be clear, are you still seeing needing to tap twice for the soft keyboard to appear specifically? The keyboard not dismissing itself after unfocusing a text field is a different issue still open at #36478. Unfortunately I don't have that specific device to test with myself at the moment.

@pedrosalesmiranda
Copy link

@mklim you are welcome. I only tested 0.3.11+2 in MI device and in this case the issue was:
first tap:
keyboard shows up and text field gets focus. But no input.
second tap:
keyboard still present and text field with focus (all apparently the same). But input is displayed now in text field.

This device is what I have with me all the time. Do you want some kind of special logs or some video of the bug happening or something that I can help you hunt the bug? We have a project that cant move forward while this happens. Actually we tested with webview on androind wihtout flutter and it worked. So might be a solution for us. But I really wanted to go on with flutter.

@pedrosalesmiranda
Copy link

pedrosalesmiranda commented Aug 29, 2019

@mklim
just tested on new version 0.3.13 still same issue not working with first tap. Should I open a new issue for this?

@mklim
Copy link
Contributor

mklim commented Aug 29, 2019

@pedrosalesmiranda yeah, I think a new issues makes sense. I think whatever is happening here is probably specific to the Mi device. Filed #39451.

If you see this reproing on any other devices or Android versions, that would be really helpful to know too.

@github-actions
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 28, 2021
@flutter-triage-bot flutter-triage-bot bot added the package flutter/packages repository. See also p: labels. label Jul 5, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
a: platform-views Embedding Android/iOS views in Flutter apps e: device-specific Only manifests on certain devices p: webview The WebView plugin package flutter/packages repository. See also p: labels. platform-android Android applications specifically
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants