Problem
When loading the map just after the login process, the map crashes pretty often, producing the following error: "Unfortunately, AppName has stopped". This intermittent crash occurs while adding the map component to its parent's view.
Some more information about the application:
• There is only one "heavy window" in the application (only one activity at once). The map is loaded on a view.
• The application window is fully loaded and displayed when loading the map component.
• The parent view is already a part of the views' hierarchy when loading the map component.
• There is only one map component in the application.
Test case
// Pseudo code representing an attempt to delay the addition of the map the view hierarchy
// If the map is put directly in the XML template, this leads to an immediate crash.
var win = Titanium.UI.createWindow({
title:'Window',
});
win.open();
var mapView = require('ti.map').createView({
animate : false,
regionFit : true,
userLocation : true,
mapType : Alloy.Globals.Map.NORMAL_TYPE
});
var mapContainer = Titanium.UI.createView();
// We now suspect that the crash could happen when we open new windows/activities during map initialization
var winWaiter = Titanium.UI.createWindow({
title:'Please wait...',
});
winWaiter.open();
// Foo application process code
setTimeout(function() {
winWaiter.close();
}, 1500);
// Intermittent crash when adding the view
mapContainer.add(mapView);
Logs
Log of the crash when the fragments are not controlled properly:
java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState
at android.support.v4.app.FragmentManagerImpl.checkStateLoss(FragmentManager.java:1327)
at android.support.v4.app.FragmentManagerImpl.enqueueAction(FragmentManager:1338)
at android.support.v4.app.BackStackRecord.commitInternal(BackStackRecord.java:595)
at android.support.v4.app.BackStackRecord.commit(BackStackRecord:574)
at android.support.v4.app.DialogFragment.show(DialogFragment:127)
General error log:
[ERROR] : TiApplication: (main) [10692,10692] Sending event: exception
on thread: main msg:java.lang.RuntimeException: Unable to pause activity
{com.ourapplication/org.appcelerator.titanium.TiTranslucentActivity}:
java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState; Titanium 3.2.3,2014/04/22 10:17,b958a70
[ERROR] : TiApplication: java.lang.RuntimeException: Unable to pause activity
{com.ourapplication/org.appcelerator.titanium.TiTranslucentActivity}:
java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState
[ERROR] : TiApplication: at android.app.ActivityThread.performPauseActivity(ActivityThread.java:3196)
[ERROR] : TiApplication: at android.app.ActivityThread.performPauseActivity(ActivityThread.java:3151)
[ERROR] : TiApplication: at android.app.ActivityThread.handlePauseActivity(ActivityThread.java:3129)
[ERROR] : TiApplication: at android.app.ActivityThread.access$900(ActivityThread.java:159)
[ERROR] : TiApplication: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1333)
[ERROR] : TiApplication: at android.os.Handler.dispatchMessage(Handler.java:99)
[ERROR] : TiApplication: at android.os.Looper.loop(Looper.java:176)
[ERROR] : TiApplication: at android.app.ActivityThread.main(ActivityThread.java:5419)
[ERROR] : TiApplication: at java.lang.reflect.Method.invokeNative(Native Method)
[ERROR] : TiApplication: at java.lang.reflect.Method.invoke(Method.java:525)
[ERROR] : TiApplication: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1046)
[ERROR] : TiApplication: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:862)
[ERROR] : TiApplication: at dalvik.system.NativeStart.main(Native Method)
[ERROR] : TiApplication: Caused by: java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState
[ERROR] : TiApplication: at android.support.v4.app.FragmentManagerImpl.checkStateLoss(FragmentManager.java:1343)
[ERROR] : TiApplication: at android.support.v4.app.FragmentManagerImpl.enqueueAction(FragmentManager.java:1361)
[ERROR] : TiApplication: at android.support.v4.app.BackStackRecord.commitInternal(BackStackRecord.java:595)
[ERROR] : TiApplication: at android.support.v4.app.BackStackRecord.commit(BackStackRecord.java:574)
[ERROR] : TiApplication: at org.appcelerator.titanium.view.TiUIFragment.<init>(TiUIFragment.java:49)
[ERROR] : TiApplication: at ti.map.TiUIMapView.<init>(TiUIMapView.java:59)
[ERROR] : TiApplication: at ti.map.ViewProxy.createView(ViewProxy.java:68)
[ERROR] : TiApplication: at org.appcelerator.titanium.proxy.TiViewProxy.handleGetView(TiViewProxy.java:463)
[ERROR] : TiApplication: at org.appcelerator.titanium.proxy.TiViewProxy.getOrCreateView(TiViewProxy.java:449)
[ERROR] : TiApplication: at org.appcelerator.titanium.proxy.TiViewProxy.realizeViews(TiViewProxy.java:487)
[ERROR] : TiApplication: at org.appcelerator.titanium.proxy.TiViewProxy.handleGetView(TiViewProxy.java:471)
[ERROR] : TiApplication: at org.appcelerator.titanium.proxy.TiViewProxy.getOrCreateView(TiViewProxy.java:449)
[ERROR] : TiApplication: at org.appcelerator.titanium.proxy.TiViewProxy.realizeViews(TiViewProxy.java:487)
[ERROR] : TiApplication: at org.appcelerator.titanium.proxy.TiViewProxy.handleGetView(TiViewProxy.java:471)
[ERROR] : TiApplication: at org.appcelerator.titanium.proxy.TiViewProxy.getOrCreateView(TiViewProxy.java:449)
[ERROR] : TiApplication: at org.appcelerator.titanium.proxy.TiViewProxy.handleAdd(TiViewProxy.java:566)
[ERROR] : TiApplication: at org.appcelerator.titanium.proxy.TiViewProxy.handleMessage(TiViewProxy.java:218)
[ERROR] : TiApplication: at android.os.Handler.dispatchMessage(Handler.java:95)
[ERROR] : TiApplication: at org.appcelerator.kroll.common.TiMessenger.dispatchMessage(TiMessenger.java:389)
[ERROR] : TiApplication: at org.appcelerator.kroll.common.TiMessenger.dispatchPendingMessages(TiMessenger.java:374)
[ERROR] : TiApplication: at org.appcelerator.kroll.common.TiMessenger$2.getResult(TiMessenger.java:252)
[ERROR] : TiApplication: at org.appcelerato
[ERROR] : TiApplication: at org.appcelerator.kroll.common.TiMessenger.sendBlockingRuntimeMessage(TiMessenger.java:186)
[ERROR] : TiApplication: at org.appcelerator.kroll.KrollProxy.fireSyncEvent(KrollProxy.java:763)
[ERROR] : TiApplication: at org.appcelerator.titanium.TiBaseActivity.onPause(TiBaseActivity.java:975)
[ERROR] : TiApplication: at org.appcelerator.titanium.TiActivity.onPause(TiActivity.java:44)
[ERROR] : TiApplication: at android.app.Activity.performPause(Activity.java:5474)
[ERROR] : TiApplication: at android.app.Instrumentation.callActivityOnPause(Instrumentation.java:1250)
[ERROR] : TiApplication: at android.app.ActivityThread.performPauseActivity(ActivityThread.java:3182)
[ERROR] : TiApplication: ... 12 more
Discussions
http://developer.appcelerator.com/question/176956/map-crash-in-android-application#comment-217798
Is there any news regarding the issue?
*edit* I just answered my own question. It looks like the navigation drawer window I'm using has a bug that causes mapviews to crash the app in exactly the manner described above. See https://github.com/manumaticx/Ti.DrawerLayout/issues/4
[~Anna] is this still an issue, we can not replicate
Yes, it's still a big issue.
Are there any particular configurations to add in the tiapp.xml for the map module? Right now, we have these configurations:
[~Anna] you must follow the docs, please check that you have your keys and everything configured correctly, here's the documentation: [Map Module| http://docs.appcelerator.com/titanium/latest/#!/api/Modules.Map ]
Radamantis, The bug that I described in this issue is fixed in the version 4.0.0 https://github.com/appcelerator/titanium_mobile/commit/3c79460d4c79473637902179d1524b41d4ea55b5
Please check the attached file. It explains the issue and provides the test case.
[~Anna] if this has been fixed in 4.0.0 we are going to close it as fixed, are you positive that you can not reproduce anymore with 4.0.0? Thanks
No, this issue cannot be closed since 4.0.0 GA is not released yet. Once it's available, I'll check it and tell you if it's OK. Do you know when 4.0.0 GA will be released?
Hello, We have tested this issue again and it works as expected. Check map image: http://oi62.tinypic.com/2e33jwl.jpg *Result:* It's not a bug. *Steps to Test:* 1. Create a classic project. 2. Paste this code in app.js file. 3. Add the map module and API key in tiapp.xml file. 4. Run this code with the testing environment. *Testing Environment:* Command-Line Interface, version 4.1.2, Ti SDK: 4.1.0.GA, Android Version: 4.2.2, 4.4.2, 5.1.0, Map module: 2.3.1, Studio Version: 4.1.1
Please let us know your test results if you notice the error existing.