[ 
https://issues.apache.org/jira/browse/CB-6837?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14143757#comment-14143757
 ] 

ASF GitHub Bot commented on CB-6837:
------------------------------------

GitHub user martincgg opened a pull request:

    https://github.com/apache/cordova-android/pull/123

    [CB-6837][Android 4.0.x branch] Fix: leaked window when hitting back button 
while alert being rendered

    CB-6837
    It is basically:
    https://github.com/apache/cordova-android/pull/122 
    Only this is refactored for 4.0.x branch.
    
    Description:
    Created arrayList on AndroidChromeClient that it will register all showed 
AlertDialog, using AndroidChromeClient class, this applies to AlertDialogs 
object, included messages, prompts and confirm AlertDialog objects.
    
    When handleDestroy() method is called on the AndroidWebView, it will 
perform a call to AndroidChromeClient class to destroy all AlerDialogs objects 
registered on the arrayList.
    This would perform a cleanup before the CordovaActivity is destroyed.
    
    dlg.show() returns an AlertDialog object, to be added to the arrayList.
    It can be:
    dialogsManager.add(dlg.show());
    But I think it looks cleaner as currently is.
    
    Tested on 4.4.2.

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/martincgg/cordova-android CB-6837_4.0.x

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/cordova-android/pull/123.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #123
    
----
commit a582fe9c9e5f7118647dceb7ed6103a976febbc6
Author: Martin Gonzalez <martin.c.glez.g...@gmail.com>
Date:   2014-09-22T20:24:47Z

    [CB-6837][Android 4.0.x] Fix: leaked window when hitting back button while 
alert being rendered
    
    Created arrayList on ChromeClient that it will register all showed
    AlertDialog, using CordovaChromeClient class, this applies to
    AlertDialogs object, included messages, prompts and confirm AlertDialog
    objects.
    
    When handleDestroy() method is called on the CordovaWebView, it will
    perform a call to ChromeClient class to destroy all AlerDialogs objects
    registered on the arrayList.
    This would perform a cleanup before the CordovaActivity is destroyed.
    
    dlg.show() returns an AlertDialog object, to be added to the arrayList.
    It can be:
    dialogsManager.add(dlg.show());
    But I think it looks cleaner as currently is.
    
    Tested on 4.2.2 & 4.4.2.

----


> Hitting Back button while alert being rendered causes leaked window
> -------------------------------------------------------------------
>
>                 Key: CB-6837
>                 URL: https://issues.apache.org/jira/browse/CB-6837
>             Project: Apache Cordova
>          Issue Type: Bug
>          Components: Android
>    Affects Versions: 3.5.0
>            Reporter: Marcel Kinard
>            Assignee: Martin Gonzalez
>         Attachments: index.html
>
>
> On master and using dialogs plugin. Using a trivial app that has a button to 
> create an alert dialog after 500ms timeout. If the Back button is hit at 
> approximately the same time as the timer expires and the alert is to be 
> shown, the following exception appears in logcat:
> D/CordovaWebView( 8178): The current URL is: 
> file:///android_asset/www/index.html
> D/CordovaWebView( 8178): The URL at item 0 is: 
> file:///android_asset/www/index.html
> D/dalvikvm(  513): GC_FOR_ALLOC freed 306K, 13% free 14164K/16240K, paused 
> 54ms, total 55ms
> D/CordovaActivity( 8178): Paused the application!
> D/CordovaWebView( 8178): Handle the pause
> W/IInputConnectionWrapper( 8178): showStatusIcon on inactive InputConnection
> W/InputMethodManagerService(  513): Starting input on non-focused client 
> com.android.internal.view.IInputMethodClient$Stub$Proxy@42396598 (uid=10050 
> pid=8178)
> D/CordovaActivity( 8178): CordovaActivity.onDestroy()
> D/CordovaWebView( 8178): >>> loadUrlNow()
> E/WindowManager( 8178): 
> E/WindowManager( 8178): android.view.WindowLeaked: Activity 
> com.example.Example has leaked window 
> com.android.internal.policy.impl.PhoneWindow$DecorView{41f0d8b8 V.E..... 
> R.....I. 0,0-465,256} that was originally added here
> E/WindowManager( 8178):       at 
> android.view.ViewRootImpl.<init>(ViewRootImpl.java:348)
> E/WindowManager( 8178):       at 
> android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:248)
> E/WindowManager( 8178):       at 
> android.view.WindowManagerImpl.addView(WindowManagerImpl.java:69)
> E/WindowManager( 8178):       at android.app.Dialog.show(Dialog.java:286)
> E/WindowManager( 8178):       at 
> android.app.AlertDialog$Builder.show(AlertDialog.java:951)
> E/WindowManager( 8178):       at 
> org.apache.cordova.CordovaChromeClient.onJsAlert(CordovaChromeClient.java:143)
> E/WindowManager( 8178):       at 
> com.android.webview.chromium.WebViewContentsClientAdapter.handleJsAlert(WebViewContentsClientAdapter.java:606)
> E/WindowManager( 8178):       at 
> com.android.org.chromium.android_webview.AwContentsClientBridge.handleJsAlert(AwContentsClientBridge.java:73)
> E/WindowManager( 8178):       at 
> com.android.org.chromium.base.SystemMessageHandler.nativeDoRunLoopOnce(Native 
> Method)
> E/WindowManager( 8178):       at 
> com.android.org.chromium.base.SystemMessageHandler.handleMessage(SystemMessageHandler.java:27)
> E/WindowManager( 8178):       at 
> android.os.Handler.dispatchMessage(Handler.java:102)
> E/WindowManager( 8178):       at android.os.Looper.loop(Looper.java:136)
> E/WindowManager( 8178):       at 
> android.app.ActivityThread.main(ActivityThread.java:5017)
> E/WindowManager( 8178):       at java.lang.reflect.Method.invokeNative(Native 
> Method)
> E/WindowManager( 8178):       at 
> java.lang.reflect.Method.invoke(Method.java:515)
> E/WindowManager( 8178):       at 
> com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
> E/WindowManager( 8178):       at 
> com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
> E/WindowManager( 8178):       at dalvik.system.NativeStart.main(Native Method)
> D/CordovaWebViewClient( 8178): onPageFinished(about:blank)
> D/CordovaActivity( 8178): onMessage(onPageFinished,about:blank)
> D/CordovaActivity( 8178): onMessage(exit,null)
> It looks like there is an attempt to show the alert dialog after the 
> activity's onDestroy() method has been called.
> When resuming the app by clicking on it's icon in the home screen or using 
> the Multitask button, the webview doesn't render completely, I see only a 
> black screen with the usual status bar. The app must be killed, and then it 
> works fine after a restart. It appears that there is a pretty small time 
> window during the timeout in which this can be reproduced, something on the 
> order of 200ms.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to