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] WebView fails to render select element in Android #25767

Closed
YukiOya opened this issue Dec 26, 2018 · 87 comments
Closed

[webview_flutter] WebView fails to render select element in Android #25767

YukiOya opened this issue Dec 26, 2018 · 87 comments
Assignees
Labels
a: annoyance Repeatedly frustrating issues with non-experimental functionality c: crash Stack traces logged to the console customer: crowd Affects or could affect many people, though not necessarily a specific customer. p: webview The WebView plugin P1 High-priority issues at the top of the work list package flutter/packages repository. See also p: labels.

Comments

@YukiOya
Copy link

YukiOya commented Dec 26, 2018

Steps to Reproduce

  1. Open a webpage include <select> element using webview_flutter.
  2. Tap it.

Logs

W/System.err: java.lang.ClassCastException: $Proxy0 cannot be cast to android.view.WindowManagerImpl
W/System.err:     at android.view.Window.setWindowManager(Window.java:766)
        at android.view.Window.setWindowManager(Window.java:747)
W/System.err:     at android.app.Dialog.<init>(Dialog.java:194)
        at android.app.AlertDialog.<init>(AlertDialog.java:201)
        at android.app.AlertDialog$Builder.create(AlertDialog.java:1099)
        at bYY.<init>(PG:6)
        at org.chromium.content.browser.input.SelectPopup.show(PG:41)
        at android.os.MessageQueue.nativePollOnce(Native Method)
        at android.os.MessageQueue.next(MessageQueue.java:326)
        at android.os.Looper.loop(Looper.java:160)
        at android.app.ActivityThread.main(ActivityThread.java:6669)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
A/chromium: [FATAL:jni_android.cc(249)] Please include Java exception stack in crash report
W/google-breakpad: ### ### ### ### ### ### ### ### ### ### ### ### ###
    Chrome build fingerprint:
    71.0.3578.99
    357809912
    ### ### ### ### ### ### ### ### ### ### ### ### ###
A/libc: Fatal signal 4 (SIGILL), code 2 (ILL_ILLOPN), fault addr 0xdf2f54af in tid 28608 (wflutterexample), pid 28608 (wflutterexample)
Application terminated.
[✓] Flutter (Channel beta, v1.0.0, on Mac OS X 10.14.2 18C54, locale ja-JP)
    • Flutter version 1.0.0 at /Users/oya/bin/flutter
    • Framework revision 5391447fae (4 weeks ago), 2018-11-29 19:41:26 -0800
    • Engine revision 7375a0f414
    • Dart version 2.1.0 (build 2.1.0-dev.9.4 f9ebf21297)

[✓] Android toolchain - develop for Android devices (Android SDK 28.0.3)
    • Android SDK at /Users/oya/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-1136-b06)
    • All Android licenses accepted.

[✓] iOS toolchain - develop for iOS devices (Xcode 10.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 10.1, Build version 10B61
    • ios-deploy 1.9.4
    • CocoaPods version 1.5.3

[✓] Android Studio (version 3.2)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin version 31.3.1
    • Dart plugin version 181.5656
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1136-b06)

[✓] IntelliJ IDEA Community Edition (version 2018.3.2)
    • IntelliJ at /Applications/IntelliJ IDEA CE.app
    • Flutter plugin version 31.3.4
    • Dart plugin version 183.4886.3

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

[✓] Connected device (1 available)
    • Android SDK built for x86 • emulator-5554 • android-x86 • Android 9 (API 28) (emulator)

• No issues found!
@YukiOya YukiOya changed the title webview_flutter fail to open dialog on Android webview_flutter fail to show dialog on Android Dec 26, 2018
@zoechi zoechi added c: crash Stack traces logged to the console plugin p: webview The WebView plugin labels Dec 27, 2018
@zoechi zoechi added this to the Goals milestone Dec 27, 2018
@danielRi
Copy link

Hi,
we can reproduce this error. Is there a way to get around this issue till it`s fixed?

@ecklf
Copy link

ecklf commented Mar 26, 2019

I can confirm this too for Android. I found out what causes this but haven't come up with a solution yet for flutter/webview.

@bmourat
Copy link

bmourat commented Apr 7, 2019

Any news on this issue?

Found a little hack how to make <select> tags work. Before constructing WebView in FlutterWebView constructor, just search for current activity and pass it instead.

FlutterWebView(Context context, BinaryMessenger messenger, int id, Map<String, Object> params) {
    Context activityContext = context;
    Context appContext = context.getApplicationContext();
    if (appContext instanceof FlutterApplication) {
      Activity currentActivity = ((FlutterApplication) appContext).getCurrentActivity();
      if (currentActivity != null) {
        activityContext = currentActivity;
      }
    }
    webView = new WebView(activityContext);
    // Other initialization
}

@Nazacheres
Copy link

Nazacheres commented Apr 11, 2019

This issue is such a blocker, I wouldn't consider WebView workable with it.
@bmourat Could you please describe your solution more in details? Where do you put this?

@bmourat
Copy link

bmourat commented Apr 11, 2019

@Nazacheres sure. I've edited a little bit file called FlutterWebView.java. You need to open your android project in Android Studio to view all dependencies and in the webview_flutter module find this file and replace the first line of the constructor

webView = new WebView(context);

with this:

Context activityContext = context;
Context appContext = context.getApplicationContext();
if (appContext instanceof FlutterApplication) {
    Activity currentActivity = ((FlutterApplication) appContext).getCurrentActivity();
    if (currentActivity != null) {
        activityContext = currentActivity;
    }
}
webView = new WebView(activityContext);

@Nazacheres
Copy link

Nazacheres commented Apr 11, 2019

@bmourat Thanks it works now!
Also, probably worth mentioning that you shouldn't forgot to import:

import android.app.Activity;
import io.flutter.app.FlutterApplication;

@Nazacheres
Copy link

@bmourat Anyway, it seems like I will need to switch to community edition. Cause I need text inputs for payment gateway, and due to : lucianoiam/flutter-webapp#1 (comment) its the only way :\

@iskakaushik iskakaushik changed the title webview_flutter fail to show dialog on Android [webview_flutter] WebView fails to render select element in Android Apr 25, 2019
@iskakaushik iskakaushik modified the milestones: Goals, May 2019 Apr 25, 2019
@iskakaushik iskakaushik self-assigned this Apr 25, 2019
@Hixie Hixie modified the milestones: May 2019, Overdue Jun 6, 2019
@iskakaushik iskakaushik modified the milestones: Overdue, Goals Jun 11, 2019
@danielmessi13
Copy link

I'm with the same problem, can anyone solve it?

@danielmessi13
Copy link

how to find the file that I should change? @bmourat

@bmourat
Copy link

bmourat commented Jun 13, 2019

@danielmessi13 As I described, you need to open your android project in Android Studio to view all dependencies and in the webview_flutter module find FlutterWebView file and replace the first line of the constructor, with the provided code.

@zurie
Copy link

zurie commented Jul 18, 2019

When i use the Master channel / the latest webview flutter plugin, "yes" i can see a keyboard on inputs, but when I click the select in the webview my whole app crashes.. when I try to search for the above fix, this file has been modified / re-written since some of the latest flutter fixes, (For the keyboard) but the select still seems broken to me....

@micsanbr
Copy link

@zurie: Same here, crash when opening select.

@kaushikb1996
Copy link

kaushikb1996 commented Jul 26, 2019

@zoechi I think this needs to be fixed soon as it's a major issue, it's been open for a while now.

@jvagliat
Copy link

+1

@vipulbhatia
Copy link

Any updates on this? It is still crashing the app when you click on a select tag inside webview. I can confirm this happens on Android on v0.3.13. This is a blocker for me to use in my app. Any response would be highly appreciated.

@cg021 cg021 self-assigned this May 27, 2020
@cg021 cg021 modified the milestones: Goals, July 2020 May 27, 2020
@VladyslavBondarenko
Copy link

VladyslavBondarenko commented May 27, 2020

@cg021
It should be already fixed.
I can reproduce the crash with current stable 1.17.1 (with the last version webview_flutter: ^0.3.22+1 as well), but not with current beta 1.18.0-11.1.pre or current dev 1.19.0-1.0.pre.

Code sample:

import 'package:flutter/material.dart';
import 'package:webview_flutter/webview_flutter.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(),
        body: WebView(initialUrl: 'https://html-select.netlify.app/'),
      ),
    );
  }
}
flutter doctor -v
[✓] Flutter (Channel beta, 1.18.0-11.1.pre, on Mac OS X 10.15.4 19E287, locale en-GB)
    • Flutter version 1.18.0-11.1.pre at /Users/nevercode/dev/flutter_beta
    • Framework revision 2738a1148b (2 weeks ago), 2020-05-13 15:24:36 -0700
    • Engine revision ef9215ceb2
    • Dart version 2.9.0 (build 2.9.0-8.2.beta)

 
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
    • Android SDK at /Users/nevercode/Library/Android/sdk
    • Platform android-29, build-tools 29.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_212-release-1586-b4-5784211)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 11.5)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 11.5, Build version 11E608c
    • CocoaPods version 1.9.1

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

[✓] Android Studio (version 3.6)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin version 45.1.1
    • Dart plugin version 192.7761
    • Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b4-5784211)

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

[✓] Connected device (4 available)
    • Redmi Note 7       • 6345c469                                 • android-arm64  • Android 9 (API 28)
    • Nevercode’s iPhone • b668e524315069f3db3661ac11ff1f66afafebdb • ios            • iOS 13.5
    • Web Server         • web-server                               • web-javascript • Flutter Tools
    • Chrome             • chrome                                   • web-javascript • Google Chrome 83.0.4103.61

• No issues found!

@pmrajani
Copy link

It's still same

W/System.err(12384): java.lang.ClassCastException: $Proxy1 cannot be cast to android.view.WindowManagerImpl
W/System.err(12384): 	at android.view.Window.setWindowManager(Window.java:778)
W/System.err(12384): 	at android.view.Window.setWindowManager(Window.java:760)
W/System.err(12384): 	at android.app.Dialog.<init>(Dialog.java:280)
W/System.err(12384): 	at android.app.AlertDialog.<init>(AlertDialog.java:205)
W/System.err(12384): 	at android.app.AlertDialog$Builder.create(AlertDialog.java:1112)
W/System.err(12384): 	at PA.<init>(PG:6)
W/System.err(12384): 	at org.chromium.content.browser.input.SelectPopup.show(PG:12)
W/System.err(12384): 	at android.os.MessageQueue.nativePollOnce(Native Method)
W/System.err(12384): 	at android.os.MessageQueue.next(MessageQueue.java:363)
W/System.err(12384): 	at android.os.Looper.loop(Looper.java:173)
W/System.err(12384): 	at android.app.ActivityThread.main(ActivityThread.java:8178)
W/System.err(12384): 	at java.lang.reflect.Method.invoke(Native Method)
W/System.err(12384): 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:513)
W/System.err(12384): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1101)
F/chromium(12384): [FATAL:jni_android.cc(249)] Please include Java exception stack in crash report
F/libc    (12384): Fatal signal 5 (SIGTRAP), code -6 (SI_TKILL) in tid 12384 (com.***), pid 12384 (com.***)
*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
Build fingerprint: 'HUAWEI/MAR-LX2/HWMAR:10/HUAWEIMAR-L22A/10.0.0.195C675:user/release-keys'
Revision: '0'
ABI: 'arm64'
Timestamp: 2020-05-27 19:49:46+0530
pid: 12384, tid: 12384, name: com.***  >>> com.*** <<<
uid: 10277
signal 5 (SIGTRAP), code -6 (SI_TKILL), fault addr --------
Abort message: '[FATAL:jni_android.cc(249)] Please include Java exception stack in crash report
'
    x0  0000000000000000  x1  0000000000000081  x2  000000007fffffff  x3  0000000000000000
    x4  0000000000000000  x5  0000000000000000  x6  0000000000000000  x7  7f7f7f7f7f7f7f7f
    x8  0000000000000000  x9  0000000000000000  x10 0000000000000001  x11 0000000000000000
    x12 0000007510324de0  x13 ffffffffffffffff  x14 0000000000000004  x15 ffffffffffffffff
    x16 0000007628d6da40  x17 0000007628cfeae0  x18 0000007629f22000  x19 0000007fd9dada70
    x20 0000007fd9dada78  x21 0000007fd9dada80  x22 000000000000004f  x23 0000007628d68508
    x24 0000007549db4000  x25 0000007629943020  x26 00000075102e0a98  x27 0000007fd9dad5c0
    x28 0000000000000070  x29 0000007fd9dada10
    sp  0000007fd9dad5b0  lr  000000754840b8b8  pc  000000754840bab8
backtrace:
      #00 pc 000000000237bab8  /data/app/com.google.android.webview--i26pHhAL9WY3BbBwmLgjA==/base.apk!libmonochrome.so (offset 0x1c3000) (BuildId: ca5bf905a3696d3f14574de03630b43792a4f9fd)
Lost connection to device.

package i am using latest webview_flutter: ^0.3.22+1 @VladyslavBondarenko

@pythoneer
Copy link

I can confirm what @VladyslavBondarenko was saying. Its running both on 1.19.0-2.0.pre.145
and 1.18.0-11.1.pre without crashes. Looks like @pmrajani is on the wrong channel.

@tomaszpolanski
Copy link
Contributor

For me, it also now works with 0.3.19+9 and 1.18.0-11.1.pre

@HassanChmsdn
Copy link

when testing my app with flutter channel beta 1.18.0-11.1.pre the dropdown worked fine, but when upgraded to stable 1.17.2 the dropdown didn't work and crashes.

Is it possible to release a bundle of the app for google play by using the flutter beta version!

@cyanglaz
Copy link
Contributor

@HassanChmsdn Yes, it is possible to release the app with flutter on beta channel.

@blasten
Copy link

blasten commented Jun 3, 2020

Duplicate of #34248.

This issue was fixed by flutter/engine#17511. Based on #58548, the current workaround is to switch to the beta channel as mentioned in the thread.

@blasten blasten closed this as completed Jun 3, 2020
@veselinnguyen
Copy link

@cg021
It should be already fixed.
I can reproduce the crash with current stable 1.17.1 (with the last version webview_flutter: ^0.3.22+1 as well), but not with current beta 1.18.0-11.1.pre or current dev 1.19.0-1.0.pre.

Code sample:

import 'package:flutter/material.dart';
import 'package:webview_flutter/webview_flutter.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(),
        body: WebView(initialUrl: 'https://html-select.netlify.app/'),
      ),
    );
  }
}

flutter doctor -v

I am using Flutter 1.18.0-11.1.pre and the bug still exists.

On iOS there is no keyboard. It opens and closes.

Screenshot 2020-06-23 at 11 13 10 PM

@VladyslavBondarenko
Copy link

Hi @veselinnguyen
consider to file a separate issue for this with filling out template

@misaelriojasftf
Copy link

Same issue here I cannot show a dropdown inside webview

W/System.err( 6872): java.lang.ClassCastException: $Proxy2 cannot be cast to android.view.WindowManagerImpl
W/System.err( 6872):    at android.view.Window.setWindowManager(Window.java:778)
W/System.err( 6872):    at android.view.Window.setWindowManager(Window.java:760)
W/System.err( 6872):    at android.app.Dialog.<init>(Dialog.java:207)
W/System.err( 6872):    at android.app.AlertDialog.<init>(AlertDialog.java:204)
W/System.err( 6872):    at android.app.AlertDialog$Builder.create(AlertDialog.java:1105)
W/System.err( 6872):    at JB.<init>(PG:6)
W/System.err( 6872):    at org.chromium.content.browser.input.SelectPopup.show(PG:41)
W/System.err( 6872):    at android.os.MessageQueue.nativePollOnce(Native Method)
W/System.err( 6872):    at android.os.MessageQueue.next(MessageQueue.java:336)
W/System.err( 6872):    at android.os.Looper.loop(Looper.java:174)
W/System.err( 6872):    at android.app.ActivityThread.main(ActivityThread.java:7356)
W/System.err( 6872):    at java.lang.reflect.Method.invoke(Native Method)
W/System.err( 6872):    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
W/System.err( 6872):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
F/chromium( 6872): [FATAL:jni_android.cc(249)] Please include Java exception stack in crash report
F/libc    ( 6872): Fatal signal 5 (SIGTRAP), code 128 (SI_KERNEL), fault addr 0x0 in tid 6872 (rg.dynastyowner), pid 6872 (rg.dynastyowner)
*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
Build fingerprint: 'google/sdk_gphone_x86/generic_x86:10/QSR1.190920.001/5891938:userdebug/dev-keys'
Revision: '0'
ABI: 'x86'
Timestamp: 2020-06-29 15:38:06-0500
pid: 6872, tid: 6872, name: rg.dynastyowner  >>> com.crg.dynastyowner <<<
uid: 10133
signal 5 (SIGTRAP), code 128 (SI_KERNEL), fault addr 0x0
Abort message: '[FATAL:jni_android.cc(249)] Please include Java exception stack in crash report
'
    eax 00000000  ebx d8305864  ecx ec207100  edx 00000400
    edi f5d25980  esi ffaa1920
    ebp ec207100  esp ffaa14b0  eip d58ecc30
backtrace:
      #00 pc 01cfdc30  /system/product/app/TrichromeLibrary/TrichromeLibrary.apk!libmonochrome.so (offset 0x66c000) (BuildId: ffe50d4377c82928759c1f40f1b35ba9f411454a)
Lost connection to device.

this is what I've got

@VladyslavBondarenko
Copy link

@misaelriojasftf with what flutter version are you experiencing this?

@willvlad
Copy link

willvlad commented Jul 8, 2020

I am having the same issue. Crashing the app whenever there is a dropdown in webview.
Using Channel beta, 1.19.0-4.3.pre
Which version has it been fixed on?

@VladyslavBondarenko
Copy link

@willvlad
I just tried with Android 9 (API 28) device this code sample #25767 (comment) using webview_flutter: ^0.3.22+1 and it's working with beta 1.19.0-4.3.pre
Consider to open a new issue with filling out template

@willvlad
Copy link

willvlad commented Jul 8, 2020

Our build is actually on stable. Is it crashing on stable for you too?

@tomaszpolanski
Copy link
Contributor

@willvlad The earliest it started to work for me is 1.18.0-11.1.pre. If your Flutter is earlier than that, it might not be fixed there

@VladyslavBondarenko
Copy link

@willvlad yes, the fix is not in stable yet

@willvlad
Copy link

willvlad commented Jul 9, 2020

It's really strange why such an important official plugin as webview remains so buggy for so long. It also sizes the view strangely and ignores keyboard types on Android, which is a pain if you have to deal with forms. I think the only real option for now is to use another plugin like the community one. It's not maintained, but at least it's not as full of bugs as the official one. I wish they spent some time on making it production ready. It's been quite a while since the release

@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 19, 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: annoyance Repeatedly frustrating issues with non-experimental functionality c: crash Stack traces logged to the console customer: crowd Affects or could affect many people, though not necessarily a specific customer. p: webview The WebView plugin P1 High-priority issues at the top of the work list package flutter/packages repository. See also p: labels.
Projects
None yet
Development

No branches or pull requests