You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by GitBox <gi...@apache.org> on 2018/12/27 07:25:32 UTC

[GitHub] hhhhub000 opened a new issue #384: Fatal Exception occured due to "not attached to window" on AndroidP

hhhhub000 opened a new issue #384: Fatal Exception occured due to "not attached to window" on AndroidP
URL: https://github.com/apache/cordova-plugin-inappbrowser/issues/384
 
 
   Steps to reproduce:
   1. Open InAppBrowser on cordova app.
   2. Move to Settings.
   3. Setting > Display > Display size. Then change display size.
   4. Resume cordova app.
   Then, App is crashed by fatal exception.
   
   ```
   Process: com.myapp, PID: 18768
   java.lang.IllegalArgumentException: View=DecorView@fb121f3[MainActivity] not attached to window manager
       at android.view.WindowManagerGlobal.findViewLocked(WindowManagerGlobal.java:497)
       at android.view.WindowManagerGlobal.removeView(WindowManagerGlobal.java:406)
       at android.view.WindowManagerImpl.removeViewImmediate(WindowManagerImpl.java:138)
       at android.app.Dialog.dismissDialog(Dialog.java:375)
       at android.app.Dialog.dismiss(Dialog.java:358)
       at org.apache.cordova.inappbrowser.InAppBrowser$5$1.onPageFinished(Unknown Source:18)
       at xf.c(SourceFile:251)
       at afs.handleMessage(SourceFile:72)
       at android.os.Handler.dispatchMessage(Handler.java:106)
       at android.os.Looper.loop(Looper.java:193)
       at android.app.ActivityThread.main(ActivityThread.java:6813)
       at java.lang.reflect.Method.invoke(Native Method)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:522)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:889)
   ```
   I think MainActivity have been destroyed and dialog is detacched when Display size is changed.
   But InAppBrowser still have old dialog and try to dismiss() when app is resumed.
   my-app\plugins\cordova-plugin-inappbrowser\src\android\InAppBrowser.java
   ```
       public void closeDialog() {
           this.cordova.getActivity().runOnUiThread(new Runnable() {
               @Override
               public void run() {
                   final WebView childView = inAppWebView;
                   // The JS protects against multiple calls, so this should happen only when
                   // closeDialog() is called by other native code.
                   if (childView == null) {
                       return;
                   }
   
                   childView.setWebViewClient(new WebViewClient() {
                       // NB: wait for about:blank before dismissing
                       public void onPageFinished(WebView view, String url) {
                           if (dialog != null) {
                               dialog.dismiss();       //!!!dialog is not attached to window
                               dialog = null;
                           }
                       }
                   });
   ```
   
   This issue is not reproduced on Android O.
   (onPageFinished is not called on Android O, So dialog.dismiss() is not called.)
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org