Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-4357] Webview fatal exception / crash on re-open

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2012-01-04T13:19:01.000+0000
Affected Version/sRelease 1.7.2
Fix Version/sSprint 2011-42, Release 1.8.0.1
ComponentsAndroid
Labelsdr-list, module_webview, qe-testadded
ReporterKT
AssigneeAllen Yeung
Created2011-06-06T20:08:00.000+0000
Updated2012-01-04T13:19:01.000+0000

Description

Open KitchenSink.

Go to Base UI > Views > Web Views > Local URL.

Then cause the app to close. NOT by force-stopping it from Settings > Applications[1], but by opening enough other applications to use up memory.

Now reopen KitchenSink. It will crash.

The output from logcat includes multiple entries such as:
E/TiBaseActivity(10988): java.lang.RuntimeException: Can't marshal non-Parcelable objects across processes.
E/TiUncaughtHandler(10988): (main) [26,9530] Sending event: exception on thread: main msg:android.view.WindowManager$BadTokenException: Unable to add window -- token android.os.BinderProxy@40514928 is not valid; is your activity running?; Titanium 1.7.0,2011/03/31 12:08,6cae16
E/TiUncaughtHandler(10988): android.view.WindowManager$BadTokenException: Unable to add window -- token android.os.BinderProxy@40514928 is not valid; is your activity running?
The result is that any Android webview-based app will crash on reopen (whether it was closed by the system, a crash, etc.) every single time. For more detail/discussion, see Q&A at: [Android webview crashes](http://developer.appcelerator.com/question/120635/android-webview-crashes----theyre-not-your-fault)

Comments

  1. Paul Dowsett 2011-06-09

    I can reliably reproduce the problem, with or without the [alwaysRetainTaskState](http://wiki.appcelerator.org/display/guides/Maintaining+a+Custom+AndroidManifest.xml#MaintainingaCustomAndroidManifest.xml-EnsuringAndroidshutsdownappscleanly) setting applied, by doing the following: * start the KS and navigating to the "Local URL" demo. Wait to finish loading. Press Home * start default apps: Alarm Clock, API Demos, Browser (navigate to [http://rgmwatches.com]), and Maps. Wait until one is fully loaded before pressing the Home button and opening the next * return to the KS webview demo. Observe "Sorry!...application has stopped unexpectedly" error Environment: * tested on emulator only * Ubuntu 10.04 * Titanium Studio, build: 1.0.0.201106071155 Build date: 07 June 2011, 11:57:46 Titanium SDK version: 1.7.0 (06/02/11 11:34 c951553...) * Android SDK 2.2 There is a video of the issue occurring [here](http://dl.dropbox.com/u/14392713/KT-KS-crash-demo.ogv), although I am not sure if there is anything further to be gleaned from it Also, logcat output is [here](http://pastebin.com/w1UkakMg)
  2. Francisco Antonio Duran Ramirez 2011-08-03

    Associated HD ticket

    Customer is relying on this, so I've increased priority, http://appc.me/c/APP-828783
  3. Joe Lepis 2011-08-12

    Any update on this?
  4. Taazza GO 2011-09-15

    Any updates on this ticket> It affects a majority of the users on 2.3.X and about 30% of users are on it. Results in a lot of crashes due to this making the app unusable. Please bump up the priority. Thanks!
  5. John Zweng 2011-09-28

    Clearly reproducable on device (Motorola Milestone, Android 2.3.4). Current Kitchen Sink application built with Titanium SDK Version: Titanium 1.7.2 (2011/07/21 09:36 97c3689) Any updates on this?
  6. Taazza GO 2011-10-11

    Folks its been a month since we requested information on this. Can you guys squeeze this in for 1.7.3. Its really impacting a lot of users. Pls revert.
  7. Allen Yeung 2011-10-19

    I am not able to reproduce the behavior where you get an error message of "Sorry!...application has stopped unexpectedly". When I switch back to the KS demo, it restarts, but it doesn't show any pop-up error message. Are there any steps that I may be missing to trigger this behavior?
  8. Taazza GO 2011-10-19

    Allen, If you would like to IM us pls reach out to us. We are online now. pls email us at support@taazza.com and we can help you reproduce it right away. Thannks!
  9. Don Thorp 2011-10-19

    The reproduction sequence should be public along with the ticket. Is there a problem adding it here?
  10. Taazza GO 2011-10-19

    We have seen this crash happen when our app opens an external app - the email app, SMS app, dialer, Google Maps app or the browser. Our app goes to the background, but gets displayed again once we close the external app. In between these actions, this crash happens. And when we reopen our app, it seems to think it is being woken up & crashes again throwing up the "Sorry..." dialog. This behaviour can be easily observed on *2.3.X* both on the emulator and on a device. The code which consistently causes this crash for us uses *Ti.Platform.openURL* to open external apps: * Open the dialer using *Ti.Platform.openURL('tel:' + )* * Open a YouTube video using *Ti.Platform.openURL* * Open Google Maps - *Ti.Platform.openURL("http://maps.google.com/maps?f=d&saddr=12,77&daddr=13,80&hl=en")* As the initial description says, having lots of applications open/running helps to reproduce this quickly.
  11. Allen Yeung 2011-10-19

    Can you please provide an app.js that I can use to reproduce this issue? I have simple code that launches google maps, and when I go back I do not see the error message you are referring to. This is what I did: 1. Open the app, and launch google maps 2. Open a bunch of other activities, like msg, browser, gallery etc 3. Go back and reopen the app The app restarts, but I don't see any error message. Please also provide step by step instructions to reproduce this. Thanks!
  12. Taazza GO 2011-10-19

    Are you trying this on 2.3.4?
  13. Allen Yeung 2011-10-19

    I am using 2.3.1 emulator
  14. Taazza GO 2011-10-19

    Its reproducible consistently on 2.3.4 devices by our users & as note by John Zweng above. Any way u can try it on 2.3.4?
  15. Allen Yeung 2011-10-19

    I just tried it on a 2.3.4 device, and I can't reproduce the error you are getting. Could you please provide an app.js and step by step instructions to reproduce this?
  16. Allen Yeung 2011-10-19

    Could you also try using Titanium SDK 1.8.0? Instructions to use the latest build are located at http://wiki.appcelerator.org/display/guides/Continuous+Builds
  17. Taazza GO 2011-10-19

    Will do. Did u try it on 1.7.X and 2.3.4?
  18. Allen Yeung 2011-10-19

    No, I only tried it on 1.8.0 and 2.3.4 There may have been other changes in 1.8.0 that have already fixed this issue.
  19. Taazza GO 2011-10-19

    If you could try it on 1.7.X branch it would help. We will try it on the device on our end when the team is back later tonite. We would have to back port the fix to 1.7.X if we can find it.
  20. Taazza GO 2011-10-20

    To reproduce the issue on 1.7.X and 1.8.0:

    Click on the *Open WebView* button. New window with webview containing dropdown opens up.

    Close the window using the back button.

    Click on the *Open WebView* button again. Webview window opens up. Now click on the dropdown. App crashes.

        Ti.UI.setBackgroundColor('#000');
        
        var tabGroup = Ti.UI.createTabGroup();
        
        var win1 = Ti.UI.createWindow({ 
            title:'Tab 1',
            backgroundColor:'#fff',
        });
        var button = Ti.UI.createButton({title: 'Open WebView'});
        win1.add(button);
        var browser = Ti.UI.createWebView();
        var html = '<html><body><select><option value="Feedback">Feedback</option><option value="Bug">Bug</option></select></body></html>';
        button.addEventListener('click', function() {
                var w = Ti.UI.createWindow({fullscreen: true});
                w.add(browser);
                w.open();
                browser.html = html;
        });
        
        tabGroup.addTab(Ti.UI.createTab({ 
            title:'Tab 1',
            window:win1
        }));
        tabGroup.open();
        
  21. Bill Dawson 2011-10-31

    pull request is ready (from allen) https://github.com/appcelerator/titanium_mobile/pull/594
  22. Kevin Whinnery 2011-10-31

    Awesome, thanks for working on this guys!
  23. Natalie Huynh 2011-12-06

    Tested with 1.8.0.1.v20111205164258 v8/rhino on Galaxy 10.1 (3.1) Droid 1 (2.2.2) Nexus S (2.3.6)
  24. Natalie Huynh 2011-12-06

    Open to add label
  25. Michael Pettiford 2012-01-04

    Reopening/closing to add/remove labels

JSON Source