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

android.view.WindowManager$BadTokenException crashes #31

Open
mikeiomo opened this issue May 29, 2017 · 9 comments
Open

android.view.WindowManager$BadTokenException crashes #31

mikeiomo opened this issue May 29, 2017 · 9 comments

Comments

@mikeiomo
Copy link

Hi,

while using the plugin for my app I noticed many crashes from the play console, the error was always this:

android.view.WindowManager$BadTokenException
com.truckmovers.cordova.RemoteInjectionPlugin$UserPromptTask$1.run

details:

android.view.WindowManager$BadTokenException:
at android.view.ViewRootImpl.setView(ViewRootImpl.java:685)
at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:328)
at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:85)
at android.app.Dialog.show(Dialog.java:325)
at com.truckmovers.cordova.RemoteInjectionPlugin$UserPromptTask$1.run(RemoteInjectionPlugin.java:312)
at android.os.Handler.handleCallback(Handler.java:815)
at android.os.Handler.dispatchMessage(Handler.java:104)
at android.os.Looper.loop(Looper.java:207)
at android.app.ActivityThread.main(ActivityThread.java:5777)
at java.lang.reflect.Method.invoke(Native Method:0)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:679)

I am using CrossWalk as webview, could this be in any way related?

@bradleyjames
Copy link
Collaborator

I'm not sure but the plugin has issues on CrossWalk. According to this SO post this plugin is instantiating the dialog correctly.

@netmikey
Copy link

Same problem here.

@bradleyjames you seem to be correlating these type of crashes with the use of crosswalk, but isn't it weird then that crosswalk doesn't show up in the call stack?

@ekleop
Copy link

ekleop commented Oct 9, 2017

We don't use crosswalk(native webview) but have the same issue. So maybe it's not related to CrossWalk?

@fmp777
Copy link

fmp777 commented Oct 20, 2017

We have the same issue too, no crosswalk. Quite a simple app really.

android.view.WindowManager$BadTokenException:
at android.view.ViewRootImpl.setView (ViewRootImpl.java:702)
at android.view.WindowManagerGlobal.addView (WindowManagerGlobal.java:342)
at android.view.WindowManagerImpl.addView (WindowManagerImpl.java:94)
at android.app.Dialog.show (Dialog.java:337)
at com.truckmovers.cordova.RemoteInjectionPlugin$UserPromptTask$1.run (RemoteInjectionPlugin.java:312)
at android.os.Handler.handleCallback (Handler.java:751)
at android.os.Handler.dispatchMessage (Handler.java:95)
at android.os.Looper.loop (Looper.java:154)
at android.app.ActivityThread.main (ActivityThread.java:6247)
at java.lang.reflect.Method.invoke (Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:872)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:762)

Crash by android version:
image

@fkoester
Copy link

fkoester commented Nov 9, 2017

Have the same error, also not using CrossWalk.

@chasefinch
Copy link

Same issue, no CrossWalk. Anyone find a solution?

@fmp777
Copy link

fmp777 commented Mar 31, 2018

image

Still a serious issue, has anyone figured out how to reproduce?

I'm thinking it has something to do with "cannot contact site" error which likes to trigger the dialog which is the thing that seems to be crashing the app because android.app.Dialog.show is not working.

Which means maybe use of

and
error.html might work around the problem?

I think the only fix is to update this repository to use new Dialog code

@fmp777
Copy link

fmp777 commented Mar 31, 2018

Its only happening when the timeout occurs during the http request to the remote site. difficult to simulate as disabling network drops directly to error.html in my case.

I dont know if its just that the Android Dialog is not getting created properly, but here is a plugin that does dialogs to get reference:
https://github.com/apache/cordova-plugin-dialogs/blob/master/src/android/Notification.java

@bradleyjames any chance on this one?

@zsoltboldizsar
Copy link

@fmp777 this issue has been fixed with #40 but it didn't end up in master on this repository.
I've added it to my fork https://github.com/zsoltboldizsar/cordova-plugin-remote-injection so anyone could directly benefit from it.

As for the fix itself, it was applied to an app I have worked on last year with +30k active users to day and there's no sign of this crash since. Hope it will help anyone coming here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants