Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-20500] Android: App relaunches when resumed from background

GitHub Issuen/a
TypeBug
PriorityCritical
StatusClosed
ResolutionFixed
Resolution Date2019-04-11T01:27:58.000+0000
Affected Version/sn/a
Fix Version/sRelease 8.0.0
ComponentsAndroid
Labelsandroid
ReporterJJ Cantillon
AssigneeJoshua Quick
Created2016-02-26T12:15:44.000+0000
Updated2019-04-11T01:28:03.000+0000

Description

Problem

This issue occurs in an app that I have made but is also occurring in the 5.2.0 Sample app ( https://github.com/appcelerator-developer-relations/appc-sample-ti520 ). This issue occurs when the app is launched and put in to the background, after multiple other apps are used if the app is launched from the android launcher or by selecting the app from the back-grounded app list the splash screen for the app will briefly show followed by what looks like the app closing and then re-opening. All state for the app is lost and while the relaunch is happening the user sees their launcher icons as if the app has crashed. This may be happening due to the app being paused or closed due to memory management but ideally the main window should show while the relaunch happens and not the launcher icons.

Test case

Build the 5.2.0 Sample app (https://github.com/appcelerator-developer-relations/appc-sample-ti520)

Install on device

Open the sample app

Background the sample app

Open other applications and switch between them until some of them start to relaunch on resume

Foreground the sample app and the bug should be recreated

Video showing relaunch behaviour

https://streamable.com/x4th

Comments

  1. Fokke Zandbergen 2016-02-26

    What exactly do you mean by _until some of them start to relaunch on resume_? I can't get that to happen on a Nexus 5.
  2. JJ Cantillon 2016-02-26

    Hi @Fokke Zandbergen Hard to explain but when you have many apps open some of the apps reload when you foreground them, generally when this happens it triggers the bug for the titanium app. I made a quick video showing the behaviour when the bug occurs: https://streamable.com/x4th
  3. Nazmus Salahin 2016-02-28

    I am not able to reproduce this issue. I created the sample app from the [link](https://github.com/appcelerator-developer-relations/appc-sample-ti520). Open the app and then backgrounded the app. And, I switched to some other apps. After that I reopen the sample app and it did open smoothly. The app resumed from the state as it was when I backgrounded the app. It did not launched showing the splash screen. *Environment*: *Device info:* Nexux7 (android 6.0.1) *Node.js Version:* 0.12.7 *npm Version:* 2.11.3 *Titanium SDKs:* 5.2.0.v20160220080449 and 5.1.2.GA *Java Development Kit Version:* 1.8.0_73 *Titanium CLI Version:* 5.0.5
  4. Luke D'Alessandro 2016-02-29

    To recreate this issue you will have to continuously open backgrounded apps until those apps open then quickly relaunch their main window. After this occurs with 3-4 different apps you then try to unbackground the appcelerator app and it will open, crash then relaunch the window as shown in the video. This may seem like an edge case, but after using your device all day this behavior becomes quite common over an extended period of time. Therefore relaunching an app that does not receive frequent use, suddenly it feels like the app has to open / crash / relaunch every time you try to use it. This behavior does not seem to occur when the device is charging, which makes it difficult to record a video of the entire process.
  5. Fokke Zandbergen 2016-03-01

    [~lukeda] unfortunately I also cannot get any backgrounded apps to relaunch when I reopen them. If you have any more leads, like an error log or something we can reopen.
  6. Sharif AbuDarda 2016-03-02

    Hello, This looks to me a device memory issue. Over an extended period of time if you put an app in the background, Relaunching the app forgot it's initial stage and start from it's home page. Though I can't generate the issue, as the reported said that the app crashes and relaunch. Any crush or error logs would be helpfull. Thanks.
  7. Michael Gangolf 2016-04-20

    Same problem here and I was able to get a log:
       04-17 12:56:09.490: I/ActivityManager(4386): START u0 {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.miga.podstars/.PodstarsActivity bnds=[540,870][804,1167] (has extras)} from uid 10055 pid 12269 on display 0
       04-17 12:56:09.527: I/ActivityManager(4386): Start proc 25370:com.miga.podstars/u0a172 for activity com.miga.podstars/org.appcelerator.titanium.TiActivity
       04-17 12:56:09.542: I/ActivityManager(4386): Start proc 25381:com.google.android.googlequicksearchbox:search/u0a55 for broadcast com.google.android.googlequicksearchbox/com.google.android.apps.gsa.search.core.icingsync.ApplicationLaunchReceiver
       04-17 12:56:09.663: D/StatusBarManagerService(4386): setSystemUiVisibility(0x8600)
       04-17 12:56:09.663: D/StatusBarManagerService(4386): disable:userId=0 what=0x0 which=0x1 pkg=Window{36a3c9c u0 Starting com.miga.podstars}
       04-17 12:56:09.663: D/StatusBarManagerService(4386): hiding MENU key
       04-17 12:56:09.744: I/TiApplication(25370): (main) [2,2] checkpoint, app created.
       04-17 12:56:09.882: I/TiApplication(25370): (main) [138,140] Titanium 5.1.2 (2015/12/16 19:00 ca822b2)
       04-17 12:56:10.018: I/TiApplication(25370): (main) [136,276] Titanium Javascript runtime: v8
       04-17 12:56:10.068: W/TiBaseActivity(25370): (main) [50,326] Runtime has been disposed or app has been killed. Finishing.
       04-17 12:56:10.115: W/TiApplication(25370): (main) [47,373] Scheduling application restart
       04-17 12:56:10.268: W/V8Object(25370): (KrollRuntimeThread) [153,526] Runtime disposed, cannot set property 'userAgent'
       04-17 12:56:10.312: I/ActivityManager(4386): Recipient 24757
       04-17 12:56:10.622: I/WindowManager(4386): Screenshot max retries 4 of Token{f433e60 ActivityRecord{fa16263 u0 com.miga.podstars/.PodstarsActivity t3924 f}} appWin=Window{3746315 u0 Starting com.miga.podstars} drawState=3
       04-17 12:56:10.622: D/ActivityManager(4386): screenshot for ActivityRecord{fa16263 u0 com.miga.podstars/.PodstarsActivity t3924 f}, bitmap=null, time = 301
       04-17 12:56:10.752: I/ActivityManager(4386): Recipient 24892
       04-17 12:56:10.767: E/InputEventReceiver(4386): Looper::removeFd(210) is failed, result(0), input channel '3746315 Starting com.miga.podstars (client)'
       04-17 12:56:10.777: W/WindowManager(4386): Failed looking up window
       04-17 12:56:10.777: W/WindowManager(4386): java.lang.IllegalArgumentException: Requested window android.view.ViewRootImpl$W@8404cc does not exist
       04-17 12:56:10.777: W/WindowManager(4386): 	at com.android.server.wm.WindowManagerService.windowForClientLocked(WindowManagerService.java:8975)
       04-17 12:56:10.777: W/WindowManager(4386): 	at com.android.server.wm.WindowManagerService.windowForClientLocked(WindowManagerService.java:8966)
       04-17 12:56:10.777: W/WindowManager(4386): 	at com.android.server.wm.WindowManagerService.removeWindow(WindowManagerService.java:2755)
       04-17 12:56:10.777: W/WindowManager(4386): 	at com.android.server.wm.Session.remove(Session.java:187)
       04-17 12:56:10.777: W/WindowManager(4386): 	at android.view.ViewRootImpl.dispatchDetachedFromWindow(ViewRootImpl.java:3244)
       04-17 12:56:10.777: W/WindowManager(4386): 	at android.view.ViewRootImpl.doDie(ViewRootImpl.java:5821)
       04-17 12:56:10.777: W/WindowManager(4386): 	at android.view.ViewRootImpl$ViewRootHandler.handleMessage(ViewRootImpl.java:3576)
       04-17 12:56:10.777: W/WindowManager(4386): 	at android.os.Handler.dispatchMessage(Handler.java:102)
       04-17 12:56:10.777: W/WindowManager(4386): 	at android.os.Looper.loop(Looper.java:168)
       04-17 12:56:10.777: W/WindowManager(4386): 	at android.os.HandlerThread.run(HandlerThread.java:61)
       04-17 12:56:10.777: W/WindowManager(4386): 	at com.android.server.ServiceThread.run(ServiceThread.java:46)
       04-17 12:56:11.213: W/OpenGLRenderer(12269): Incorrectly called buildLayer on View: ShortcutAndWidgetContainer, destroying layer...
       04-17 12:56:11.214: W/OpenGLRenderer(12269): Incorrectly called buildLayer on View: ShortcutAndWidgetContainer, destroying layer...
       04-17 12:56:11.675: I/RecentsTaskLoadPlan(5504): icon(3924,144,144)
       04-17 12:56:11.676: D/ActivityManager(4386): getTaskThumbnailLocked mainThumbnail is null, TaskRecord{b93f082 #3924 A=com.miga.podstars U=0 sz=0}
       04-17 12:56:15.764: I/ActivityManager(4386): START u0 {act=android.intent.action.MAIN at=[android.intent.category.LAUNCHER] flg=0x4 cmp=com.miga.podstars/.PodstarsActivity (has extras)} from uid 10172 pid -1 on display 0
       04-17 12:56:15.765: W/ActivityManager(4386): startActivity called from non-Activity context; forcing Intent.FLAG_ACTIVITY_NEW_TASK for: ntent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x4 cmp=com.miga.podstars/.PodstarsActivity (has extras) }
       04-17 12:56:15.773: V/AlarmManager(4386): sending alarm PendinIntent{ac33e7: PendingIntentRecord{cccab94 com.miga.podstars startActivity}}, i=android.intent.action.MAIN, t=1, cnt=1, w=1460890570762, Int=0
       04-17 12:56:15.784: I/TiRootActivity(25370): (main) [0,0] checkpoint, on root activity create, savedInstanceState: null
       04-17 12:56:15.785: I/TiApplication(25370): (main) [1,1] Analytics have been disabled
       04-17 12:56:15.926: D/Module(25370): Loading module: alloy -> Resources/alloy.js
       04-17 12:56:15.941: D/Module(25370): Loading module: alloy/underscore -> Resources/alloy/underscore.js
       04-17 12:56:16.018: D/Module(25370): Loading module: alloy/backbone -> Resources/alloy/backbone.js
       04-17 12:56:16.056: D/Module(25370): Loading module: alloy/constants -> Resources/alloy/constants.js
       04-17 12:56:16.076: D/Module(25370): Loading module: alloy/CFG -> Resources/alloy/CFG.js
       04-17 12:56:16.078: D/Module(25370): Loading module: alloy/controllers/index -> Resources/alloy/controllers/index.js
       04-17 12:56:16.089: D/Module(25370): Loading module: alloy/controllers/BaseController -> Resources/alloy/controllers/BaseController.js
       04-17 12:56:16.114: D/Module(25370): Loading module: alloy/styles/index -> Resources/alloy/styles/index.js
       04-17 12:56:16.174: I/ActivityManager(4386): START u0 {cmp=com.miga.podstars/org.appcelerator.titanium.TiActivity (has extras)} from uid 10172 pid 25370 on display 0
       04-17 12:56:16.268: I/TiRootActivity(25370): (main) [0,0] checkpoint, on root activity resume. activity = com.miga.podstars.PodstarsActivity@c04b27d
       04-17 12:56:16.363: W/TiUIScrollView(25370): (main) [95,95] Scroll direction could not be determined based on the provided view properties. Default VERTICAL scroll direction being used. Use the 'scrollType' property to explicitly set the scrolling direction.
       04-17 12:56:16.383: W/TiUICardView(25370): (main) [20,115] The cardCornerRadius property is deprecated, use borderRadius instead.
       04-17 12:56:16.384: W/TiUICardView(25370): (main) [1,116] The cardUseCompatPadding property is deprecated, use useCompatPadding instead.
       04-17 12:56:16.385: W/TiUICardView(25370): (main) [1,117] The contentPadding property is deprecated, use padding instead.
       04-17 12:56:16.405: W/TiUICardView(25370): (main) [20,137] The cardCornerRadius property is deprecated, use borderRadius instead.
       04-17 12:56:16.405: W/TiUICardView(25370): (main) [0,137] The cardUseCompatPadding property is deprecated, use useCompatPadding instead.
       04-17 12:56:16.406: W/TiUICardView(25370): (main) [1,138] The contentPadding property is deprecated, use padding instead.
       04-17 12:56:16.412: D/Window(25370): Checkpoint: postWindowCreated()
       
       ....normal app start.....
       
    It is not happening all the time but even with 5.2.2.GA I can reproduce it after a while. Android 6.0.1 (HTC A9) Android 5.1.1 (Nexus 4) Doesn't happen with "non-Titanium" apps as far as I can say. But I'll keep an eye on that too
  8. Patrick Mounteney 2016-07-20

    I am also seeing this as in Michael G's log but I am building with Ti SDK 5.3.0 and testing on a Nexus 7 under Android 6.0.1 Is it simply the OS reclaiming memory? What would we expect to see in a log under those circumstances? The error message 'Runtime has been disposed or app has been killed. Finishing.' is coming from TiBaseActivity.java described as being in response to: // If all the activities has been killed and the runtime has been disposed or the app's hosting process has // been killed, we cannot recover one specific activity because the info of the top-most view proxy has been // lost (TiActivityWindows.dispose()). In this case, we have to restart the app. Which seems a bit of a catch-all. Can anybody enlighten us?
  9. David Fox 2016-09-25

    I'm seeing this too and I'm not sure exactly what's happening. Anyone figure anything out?
  10. David Fox 2016-09-26

    Another issue I'm seeing with this - it seems like on older versions of Android the restart actually works without the user seeing a crash dialog, but in newer versions of Android, from what I'm seeing in 7.0 crash reports, the restart doesn't even work and it instead results in a visible app crash with the very non-descriptive crash report "Native crash at /data/app/com.hexicallabs.devrant-1/lib/arm/libkroll-v8.so"
  11. David Fox 2016-09-26

    An update - I'm trying to come up with a patch for the restart functionality Michael pointed out to stop the crash from occurring during restart. If anyone has any ideas, please let me know and I'm happy to modify the code, compile, test and contribute back anything that works. So far I've tried increasing the restart delay, removing savedInstanceState in onCreate, and a few other things, but haven't had any luck at preventing the crash from occurring. By the way, I found an easy way to reproduce it in the emulator for those who have had trouble (I'm using a Nexus 5X emulator running Android 7). I just set the device memory to something low, like 600mb for example. Open the app, then background it and start opening a bunch of other apps. When you back to your app and the OS has tried to kill, Titanium attempts an app restart which fails and the user sees a crash. The behavior mimics what my users are seeing on their devices. Any help is appreciated.
  12. Michael Gangolf 2016-10-12

    Output of 6.0.0.v20161005072811 Problem still exists: {noformat} I/ActivityManager(4384): Start proc 4804:com.miga.podstars/u0a172 for activity com.miga.podstars/org.appcelerator.titanium.TiActivity I/TiApplication(4804): (main) [0,0] checkpoint, app created. I/TiApplication(4804): (main) [62,62] Titanium 6.0.0 (2016/10/05 07:28 undefined) I/TiApplication(4804): (main) [78,140] Titanium Javascript runtime: v8 W/TiBaseActivity(4804): (main) [30,170] Runtime has been disposed or app has been killed. Finishing. W/TiApplication(4804): (main) [27,197] Scheduling application restart D/ActivityManager(4384): screenshot for ActivityRecord{5cd3572 u0 com.miga.podstars/.PodstarsActivity t15232 f}, bitmap=null, time = 0 E/BufferQueueProducer(515): [Starting com.miga.podstars] queueBuffer: BufferQueue has been abandoned E/Surface(4384): queueBuffer: error queuing buffer to SurfaceTexture, -19 E/Surface(4384): queueBuffer (handle=0x556673b150) failed (No such device) E/ViewRootImpl(4384): Could not unlock surface E/ViewRootImpl(4384): java.lang.IllegalArgumentException E/ViewRootImpl(4384): at android.view.Surface.nativeUnlockCanvasAndPost(Native Method) E/ViewRootImpl(4384): at android.view.Surface.unlockSwCanvasAndPost(Surface.java:301) E/ViewRootImpl(4384): at android.view.Surface.unlockCanvasAndPost(Surface.java:282) E/ViewRootImpl(4384): at android.view.ViewRootImpl.drawSoftware(ViewRootImpl.java:2884) E/ViewRootImpl(4384): at android.view.ViewRootImpl.draw(ViewRootImpl.java:2787) E/ViewRootImpl(4384): at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:2564) E/ViewRootImpl(4384): at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2164) E/ViewRootImpl(4384): at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1174) E/ViewRootImpl(4384): at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6241) E/ViewRootImpl(4384): at android.view.Choreographer$CallbackRecord.run(Choreographer.java:873) E/ViewRootImpl(4384): at android.view.Choreographer.doCallbacks(Choreographer.java:676) E/ViewRootImpl(4384): at android.view.Choreographer.doFrame(Choreographer.java:606) E/ViewRootImpl(4384): at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:859) E/ViewRootImpl(4384): at android.os.Handler.handleCallback(Handler.java:739) E/ViewRootImpl(4384): at android.os.Handler.dispatchMessage(Handler.java:95) E/ViewRootImpl(4384): at android.os.Looper.loop(Looper.java:168) E/ViewRootImpl(4384): at android.os.HandlerThread.run(HandlerThread.java:61) E/ViewRootImpl(4384): at com.android.server.ServiceThread.run(ServiceThread.java:46) W/WindowManager(4384): Failed looking up window W/WindowManager(4384): java.lang.IllegalArgumentException: Requested window android.view.ViewRootImpl$W@dbc7fa7 does not exist W/WindowManager(4384): at com.android.server.wm.WindowManagerService.windowForClientLocked(WindowManagerService.java:8975) W/WindowManager(4384): at com.android.server.wm.WindowManagerService.windowForClientLocked(WindowManagerService.java:8966) W/WindowManager(4384): at com.android.server.wm.WindowManagerService.finishDrawingWindow(WindowManagerService.java:3540) W/WindowManager(4384): at com.android.server.wm.Session.finishDrawing(Session.java:232) W/WindowManager(4384): at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:2613) W/WindowManager(4384): at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2164) W/WindowManager(4384): at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1174) W/WindowManager(4384): at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6241) W/WindowManager(4384): at android.view.Choreographer$CallbackRecord.run(Choreographer.java:873) W/WindowManager(4384): at android.view.Choreographer.doCallbacks(Choreographer.java:676) W/WindowManager(4384): at android.view.Choreographer.doFrame(Choreographer.java:606) W/WindowManager(4384): at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:859) W/WindowManager(4384): at android.os.Handler.handleCallback(Handler.java:739) W/WindowManager(4384): at android.os.Handler.dispatchMessage(Handler.java:95) W/WindowManager(4384): at android.os.Looper.loop(Looper.java:168) W/WindowManager(4384): at android.os.HandlerThread.run(HandlerThread.java:61) W/WindowManager(4384): at com.android.server.ServiceThread.run(ServiceThread.java:46) W/WindowManager(4384): Failed looking up window W/WindowManager(4384): java.lang.IllegalArgumentException: Requested window android.view.ViewRootImpl$W@dbc7fa7 does not exist W/WindowManager(4384): at com.android.server.wm.WindowManagerService.windowForClientLocked(WindowManagerService.java:8975) W/WindowManager(4384): at com.android.server.wm.WindowManagerService.windowForClientLocked(WindowManagerService.java:8966) W/WindowManager(4384): at com.android.server.wm.WindowManagerService.finishDrawingWindow(WindowManagerService.java:3540) W/WindowManager(4384): at com.android.server.wm.Session.finishDrawing(Session.java:232) W/WindowManager(4384): at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:2613) W/WindowManager(4384): at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2164) W/WindowManager(4384): at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1174) W/WindowManager(4384): at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6241) W/WindowManager(4384): at android.view.Choreographer$CallbackRecord.run(Choreographer.java:873) W/WindowManager(4384): at android.view.Choreographer.doCallbacks(Choreographer.java:676) W/WindowManager(4384): at android.view.Choreographer.doFrame(Choreographer.java:606) W/WindowManager(4384): at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:859) W/WindowManager(4384): at android.os.Handler.handleCallback(Handler.java:739) W/WindowManager(4384): at android.os.Handler.dispatchMessage(Handler.java:95) W/WindowManager(4384): at android.os.Looper.loop(Looper.java:168) W/WindowManager(4384): at android.os.HandlerThread.run(HandlerThread.java:61) W/WindowManager(4384): at com.android.server.ServiceThread.run(ServiceThread.java:46) W/InputMethodManagerService(4384): Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy@164484a attribute=EditorInfo { packageName=com.google.android.googlequicksearchbox, inputType=0x0, imeOptions=0x0, privateImeOptions=null }, token = android.os.BinderProxy@a57c0f9, client pid=2945, inputType=0x0 E/InputEventReceiver(4384): Looper::removeFd(407) is failed, result(0), input channel 'a516c54 Starting com.miga.podstars (client)' W/WindowManager(4384): Failed looking up window W/WindowManager(4384): java.lang.IllegalArgumentException: Requested window android.view.ViewRootImpl$W@dbc7fa7 does not exist W/WindowManager(4384): at com.android.server.wm.WindowManagerService.windowForClientLocked(WindowManagerService.java:8975) W/WindowManager(4384): at com.android.server.wm.WindowManagerService.windowForClientLocked(WindowManagerService.java:8966) W/WindowManager(4384): at com.android.server.wm.WindowManagerService.removeWindow(WindowManagerService.java:2755) W/WindowManager(4384): at com.android.server.wm.Session.remove(Session.java:187) W/WindowManager(4384): at android.view.ViewRootImpl.dispatchDetachedFromWindow(ViewRootImpl.java:3244) W/WindowManager(4384): at android.view.ViewRootImpl.doDie(ViewRootImpl.java:5821) W/WindowManager(4384): at android.view.ViewRootImpl$ViewRootHandler.handleMessage(ViewRootImpl.java:3576) W/WindowManager(4384): at android.os.Handler.dispatchMessage(Handler.java:102) W/WindowManager(4384): at android.os.Looper.loop(Looper.java:168) W/WindowManager(4384): at android.os.HandlerThread.run(HandlerThread.java:61) W/WindowManager(4384): at com.android.server.ServiceThread.run(ServiceThread.java:46) I/ActivityManager(4384): Start proc 4836:com.google.process.gapps/u0a16 for content provider com.google.android.gsf/.gservices.GservicesProvider W/System(4836): ClassLoader referenced unknown path: /system/priv-app/GoogleServicesFramework/lib/arm64 W/V8Object(4804): (KrollRuntimeThread) [546,743] Runtime disposed, cannot set property 'userAgent' I/MemoryTrimmer(4794): Trimming objects from memory, since app is in the background. I/ActivityManager(4384): Start proc 4859:com.google.android.partnersetup/u0a20 for content provider com.google.android.partnersetup/.RlzAppProvider E/lowmemorykiller(512): Error writing /proc/4691/oom_score_adj; errno=22 E/JavaBinder(4384): !!! FAILED BINDER TRANSACTION !!! (parcel size = 76) I/ActivityManager(4384): Recipient 4691 E/InputEventReceiver(5753): Looper::removeFd(41) is failed, result(0), input channel 'ClientState{8683c1b uid 10391 pid 4691} (client)' W/System(4859): ClassLoader referenced unknown path: /system/priv-app/GooglePartnerSetup/lib/arm64 W/ActivityManager(4384): startActivity called from non-Activity context; forcing Intent.FLAG_ACTIVITY_NEW_TASK for: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x4 cmp=com.miga.podstars/.PodstarsActivity (has extras) } I/TiRootActivity(4804): (main) [0,0] checkpoint, on root activity create, savedInstanceState: null I/TiApplication(4804): (main) [1,1] Analytics have been disabled I/ActivityManager(4384): START u0 {cmp=com.miga.podstars/org.appcelerator.titanium.TiActivity (has extras)} from uid 10172 pid 4804 on display 0 I/TiRootActivity(4804): (main) [0,0] checkpoint, on root activity resume. activity = com.miga.podstars.PodstarsActivity@ef48ad4 D/Window(4804): Checkpoint: postWindowCreated() I/ActivityManager(4384): Displayed com.miga.podstars/org.appcelerator.titanium.TiActivity: +222ms (total +6s260ms) {noformat} Some patches have been applied here: https://github.com/appcelerator/titanium_mobile/pull/8472 for other start/resume issues but they didn't have any impact on this issue
  13. Darius G 2016-11-08

    I can confirm that SDK 5.5.1(Windows) still has this problem. Tested with TODO app from appcelerator. Also on my own app. Crashes. It works fine on first launch but if you switch between other (memory consuming apps) then back to titanium app it will crash on resume from task swicher window [(image from internet)](http://www.androidpolice.com/wp-content/uploads/2014/10/nexus2cee_43.png) Phone LG G2 mini, Android 5.0.2
  14. Reymundo López 2017-01-10

    We are seeing this same issue with a large production app using Ti 6.0.X.
  15. Michael Gangolf 2017-02-17

    Still doing some more debugging here and finally recorded a video of the problem: http://www.migaweb.de/video.mp4 happens with all Titanium apps sooner or later. * App is running * putting it into background (not closing it!) * running some other apps * returning to the Ti app will open it, close it, wait 5 sec and restart it! I've added some logs (sorry its getting very messy now :-) ) in the TiBaseActivity and TiLaunchActivity to see whats going on and had a look at isUnsupportedReLaunch since that decides if it failed. *Normal start of an app:* * isUnsupportedReLaunch: null || com.miga.bs.appActivity@f3cbe7b || true || 0 * isUnsupportedReLaunch: null || com.miga.bs.appActivity@f3cbe7b || true || 0 * isUnsupportedReLaunch: null || com.miga.bs.appActivity@f3cbe7b || true || 0 * I/RESTART start(21793): start * I/RESTART resume(21793): resume * I/RESTART base(21793): resume * I/RESTART pause(21793): pause * isUnsupportedReLaunch: null || org.appcelerator.titanium.TiActivity@2561c2f || false || 0 * I/RESTART base(21793): resume * I/RESTART CHECK(21793): base stop isUnsupportedReLaunch is checked 4 times (values are savedInstanceState + " || " + activity + " || " + KrollRuntime.isDisposed() + " || " + TiApplication.getInstance().rootActivityLatch.getCount()}) *Normal resume:* * I/RESTART base(21793): restart * I/RESTART base(21793): resume *Here is the resume when the crash happens:* * 11:58:57.693: I/RESTART CHECK(21793): base stop * 11:59:08.586: isUnsupportedReLaunch: || org.appcelerator.titanium.TiActivity@a466377 || true || 1 (<---- 1) * 11:59:10.618: I/RESTART destroy(23153): destroy * 11:59:10.618: I/RESTART destroy(23153): isRestartPending * 11:59:15.714: isUnsupportedReLaunch: null || com.miga.bs.appActivity@3469c82 || false || 1 * 11:59:15.720: isUnsupportedReLaunch: null || com.miga.bs.appActivity@3469c82 || false || 0 * 11:59:15.721: isUnsupportedReLaunch: null || com.miga.bs.appActivity@3469c82 || false || 0 * 11:59:16.561: I/RESTART start(23153): start * 11:59:16.564: I/RESTART resume(23153): resume * 11:59:16.564: I/RESTART base(23153): resume * 11:59:16.578: I/RESTART pause(23153): pause * 11:59:16.594: isUnsupportedReLaunch: null || org.appcelerator.titanium.TiActivity@6a45fbb || false || 0 * 11:59:17.055: I/RESTART base(23153): resume * 11:59:17.801: I/RESTART CHECK(23153): base stop As you can see by the times: you have a 5 sec gap between onDestroy/isRestartPending and the relaunch. This is here: https://github.com/appcelerator/titanium_mobile/blob/master/android/titanium/src/java/org/appcelerator/titanium/TiLaunchActivity.java#L446 After the isRestartPending it is doing the normal "app start" routine. So the resume is not starting with restart/resume but with a onStop from n the TiBaseActivity. I know that the android system is allowed to kill apps in background but it is very annoying if the restart looks like this: starting the app, leave a white screen, close it, wait 5sec, restart it. If it would just do the restart it would be perfectly fine (ok, better if it would just resume it :-) ) *One other thing I've noticed*: when the app starts the fist time (so right after ti build and deploy) it will resume like this: * I/RESTART base(21793): restart * I/RESTART base(21793): resume * I/RESTART destroy(21793): destroy * I/RESTART destroy(21793): finishing2373 so it is going into onDestroy (TiLaunchActivity) with finishing2373=true all the time! Once I close it with the back button (destroy and onStop in BaseActivity) it will run the logs above so without destroy and finishing2373! Edit: This is the commit that introduced the restart from an unsupported state in 2012: https://github.com/appcelerator/titanium_mobile/commit/64f9a05fb80e44bcc2dffd88f67da204ec26cf15
  16. Michael Gangolf 2017-02-20

    Testing https://github.com/appcelerator/titanium_mobile/pull/8843 results in a quicker restart but also leads to this crash when closing a restarted app:
        
        I/TiApplication(22686): (main) [1,1] checkpoint, app created.
        I/TiApplication(22686): (main) [63,64] Titanium 6.1.0 (2017/02/20 17:29 undefined)
        I/TiApplication(22686): (main) [37,101] Analytics have been disabled
        I/TiApplication(22686): (main) [34,135] Titanium Javascript runtime: v8
        I/RESTART(22686): (main) [61,196] Bundle[{android:viewHierarchyState=Bundle[mParcelledData.dataSize=4292]}] || org.appcelerator.titanium.TiActivity@a8a2176 || true || 1
        W/TiBaseActivity(22686): (main) [1,197] Runtime has been disposed or app has been killed. Finishing.
        I/RESTART(22686): (main) [28,225] Bundle[{android:viewHierarchyState=Bundle[mParcelledData.dataSize=272]}] || com.miga.podstars.PodstarsActivity@8efe94e || true || 1
        I/TiRootActivity(22686): (main) [0,0] checkpoint, on root activity create, savedInstanceState: Bundle[{android:viewHierarchyState=Bundle[mParcelledData.dataSize=272]}]
        I/RESTART(22686): (main) [3,3] Bundle[{android:viewHierarchyState=Bundle[mParcelledData.dataSize=272]}] || com.miga.podstars.PodstarsActivity@8efe94e || true || 0
        I/RESTART(22686): (main) [2,5] Bundle[{android:viewHierarchyState=Bundle[mParcelledData.dataSize=272]}] || com.miga.podstars.PodstarsActivity@8efe94e || true || 0
        I/RESTART start(22686): (main) [534,539] start
        I/TiRootActivity(22686): (main) [0,0] checkpoint, on root activity resume. activity = com.miga.podstars.PodstarsActivity@8efe94e
        I/RESTART resume(22686): (main) [0,0] resume
        I/RESTART base(22686): (main) [0,0] resume
        W/V8Object(22686): (KrollRuntimeThread) [191,191] Runtime disposed, cannot set property 'visible'
        W/V8Object(22686): (KrollRuntimeThread) [1,192] Runtime disposed, cannot set property 'enabled'
        W/V8Object(22686): (KrollRuntimeThread) [0,192] Runtime disposed, cannot set property 'hiddenBehavior'
        W/V8Object(22686): (KrollRuntimeThread) [0,192] Runtime disposed, cannot set property 'backgroundRepeat'
        W/V8Object(22686): (KrollRuntimeThread) [0,192] Runtime disposed, cannot set property 'windowPixelFormat'
        W/V8Object(22686): (KrollRuntimeThread) [0,192] Runtime disposed, cannot set property 'touchEnabled'
        W/V8Object(22686): (KrollRuntimeThread) [5,197] Runtime disposed, cannot set property 'visible'
        W/V8Object(22686): (KrollRuntimeThread) [0,197] Runtime disposed, cannot set property 'enabled'
        W/V8Object(22686): (KrollRuntimeThread) [0,197] Runtime disposed, cannot set property 'contentOffset'
        W/V8Object(22686): (KrollRuntimeThread) [0,197] Runtime disposed, cannot set property 'hiddenBehavior'
        W/V8Object(22686): (KrollRuntimeThread) [0,197] Runtime disposed, cannot set property 'backgroundRepeat'
        W/V8Object(22686): (KrollRuntimeThread) [0,197] Runtime disposed, cannot set property 'overScrollMode'
        W/V8Object(22686): (KrollRuntimeThread) [0,197] Runtime disposed, cannot set property 'touchEnabled'
        W/V8Object(22686): (KrollRuntimeThread) [1,198] Runtime disposed, cannot set property 'enabled'
        W/V8Object(22686): (KrollRuntimeThread) [0,198] Runtime disposed, cannot set property 'hiddenBehavior'
        W/V8Object(22686): (KrollRuntimeThread) [0,198] Runtime disposed, cannot set property 'backgroundRepeat'
        W/V8Object(22686): (KrollRuntimeThread) [0,198] Runtime disposed, cannot set property 'touchEnabled'
        W/V8Object(22686): (KrollRuntimeThread) [2,200] Runtime disposed, cannot set property 'visible'
        W/V8Object(22686): (KrollRuntimeThread) [0,200] Runtime disposed, cannot set property 'enabled'
        W/V8Object(22686): (KrollRuntimeThread) [0,200] Runtime disposed, cannot set property 'hiddenBehavior'
        W/V8Object(22686): (KrollRuntimeThread) [0,200] Runtime disposed, cannot set property 'backgroundRepeat'
        W/V8Object(22686): (KrollRuntimeThread) [0,200] Runtime disposed, cannot set property 'touchEnabled'
        W/V8Object(22686): (KrollRuntimeThread) [10,210] Runtime disposed, cannot set property 'visible'
        W/V8Object(22686): (KrollRuntimeThread) [0,210] Runtime disposed, cannot set property 'visible'
        W/V8Object(22686): (KrollRuntimeThread) [13,223] Runtime disposed, cannot set property 'validatesSecureCertificate'
        W/V8Object(22686): (KrollRuntimeThread) [28,251] Runtime disposed, cannot set property 'validatesSecureCertificate'
        W/V8Object(22686): (KrollRuntimeThread) [6,257] Runtime disposed, cannot set property 'validatesSecureCertificate'
        W/V8Object(22686): (KrollRuntimeThread) [5,262] Runtime disposed, cannot set property 'validatesSecureCertificate'
        W/V8Object(22686): (KrollRuntimeThread) [5,267] Runtime disposed, cannot set property 'validatesSecureCertificate'
        W/V8Object(22686): (KrollRuntimeThread) [5,272] Runtime disposed, cannot set property 'validatesSecureCertificate'
        W/V8Object(22686): (KrollRuntimeThread) [4,276] Runtime disposed, cannot set property 'validatesSecureCertificate'
        W/V8Object(22686): (KrollRuntimeThread) [4,280] Runtime disposed, cannot set property 'validatesSecureCertificate'
        W/V8Object(22686): (KrollRuntimeThread) [4,284] Runtime disposed, cannot set property 'validatesSecureCertificate'
        I/RESTART pause(22686): (main) [16,300] pause
        I/RESTART(22686): (main) [10,310] null || org.appcelerator.titanium.TiActivity@b9c5dc2 || true || 0
        W/TiApplication(22686): (KrollRuntimeThread) [226,536] Registering module with name already in use.
        I/RESTART base(22686): (main) [107,643] resume
        I/WindowState(4367): WIN DEATH: Window{7c9d69c u0 acr.browser.lightning/acr.browser.lightning.activity.MainActivity}
        I/RESTART CHECK(22686): (main) [443,1086] base stop
        E/JNIUtil(22686): ProxyFactory: failed to find class for ti.modules.titanium.ui.ViewProxy
        E/ProxyFactory(22686): No proxy info found for class.
        E/TiViewProxy(22686): (KrollRuntimeThread) [15917,17003] Add called with a null child
        A/DEBUG(3695): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
        A/DEBUG(3695): Build fingerprint: 'htc/hiaeuhl_00401/htc_hiaeuhl:6.0.1/MMB29M/684509.81:user/release-keys'
        A/DEBUG(3695): Revision: '0'
        A/DEBUG(3695): ABI: 'arm'
        A/DEBUG(3695): pid: 22686, tid: 22700, name: KrollRuntimeThr  >>> com.miga.podstars <<<
        A/DEBUG(3695): signal 6 (SIGABRT), code -6 (SI_TKILL), fault addr --------
        A/DEBUG(3695): Abort message: 'art/runtime/java_vm_ext.cc:448] JNI DETECTED ERROR IN APPLICATION: obj == null'
        A/DEBUG(3695):     r0 00000000  r1 000058ac  r2 00000006  r3 f3c4c978
        A/DEBUG(3695):     r4 f3c4c980  r5 f3c4c930  r6 00000002  r7 0000010c
        A/DEBUG(3695):     r8 ab39b6d0  r9 f4f6437c  sl 00000000  fp 00000000
        A/DEBUG(3695):     ip 00000006  sp f3c4bb50  lr f6eefa9d  pc f6ef1e98  cpsr 40070010
        A/DEBUG(3695): backtrace:
        A/DEBUG(3695):     #00 pc 00044e98  /system/lib/libc.so (tgkill+12)
        A/DEBUG(3695):     #01 pc 00042a99  /system/lib/libc.so (pthread_kill+32)
        A/DEBUG(3695):     #02 pc 0001badf  /system/lib/libc.so (raise+10)
        A/DEBUG(3695):     #03 pc 00018c81  /system/lib/libc.so (__libc_android_abort+34)
        A/DEBUG(3695):     #04 pc 00016840  /system/lib/libc.so (abort+4)
        A/DEBUG(3695):     #05 pc 003244c9  /system/lib/libart.so (_ZN3art7Runtime5AbortEv+212)
        A/DEBUG(3695):     #06 pc 000f415d  /system/lib/libart.so (_ZN3art10LogMessageD2Ev+2212)
        A/DEBUG(3695):     #07 pc 00252af3  /system/lib/libart.so (_ZN3art9JavaVMExt8JniAbortEPKcS2_+1510)
        A/DEBUG(3695):     #08 pc 00252efd  /system/lib/libart.so (_ZN3art9JavaVMExt9JniAbortFEPKcS2_z+68)
        A/DEBUG(3695):     #09 pc 0028aa59  /system/lib/libart.so (_ZN3art3JNI15CallVoidMethodAEP7_JNIEnvP8_jobjectP10_jmethodIDP6jvalue+440)
        A/DEBUG(3695):     #10 pc 002faf6d  /data/app/com.miga.podstars-2/lib/arm/libkroll-v8.so (_ZN8titanium11TiViewProxy3addERKN2v820FunctionCallbackInfoINS1_5ValueEEE+244)
        A/DEBUG(3695):     #11 pc 003c8dc0  /data/app/com.miga.podstars-2/lib/arm/libkroll-v8.so (_ZN2v88internal25FunctionCallbackArguments4CallEPFvRKNS_20FunctionCallbackInfoINS_5ValueEEEE+136)
        A/DEBUG(3695):     #12 pc 004197c8  /data/app/com.miga.podstars-2/lib/arm/libkroll-v8.so
        A/DEBUG(3695):     #13 pc 00419e38  /data/app/com.miga.podstars-2/lib/arm/libkroll-v8.so
        A/DEBUG(3695):     #14 pc 00000098  <unknown>
        A/DEBUG(3695): Tombstone written to: /data/tombstones/tombstone_05
        E/DEBUG(3695): AM write failed: Broken pipe
        I/DEBUG(3695): Write to AM fail, close AM fd
        I/WindowState(4367): WIN DEATH: Window{4e4faca u0 com.miga.podstars/com.miga.podstars.PodstarsActivity}
        I/WindowState(4367): WIN DEATH: Window{9a41c9c u0 com.miga.podstars/org.appcelerator.titanium.TiActivity}
        I/LoadedApk(22747): No resource references to update in package FFFFFFFFFFFFFFFFFFFFFF
        I/TiApplication(22759): (main) [0,0] checkpoint, app created.
        I/TiApplication(22759): (main) [59,59] Titanium 6.1.0 (2017/02/20 17:29 undefined)
        I/TiApplication(22759): (main) [20,79] Analytics have been disabled
        I/TiApplication(22759): (main) [21,100] Titanium Javascript runtime: v8
        I/RESTART(22759): (main) [29,129] Bundle[{android:viewHierarchyState=Bundle[mParcelledData.dataSize=272]}] || com.miga.podstars.PodstarsActivity@a8a2176 || true || 1
        I/TiRootActivity(22759): (main) [0,0] checkpoint, on root activity create, savedInstanceState: Bundle[{android:viewHierarchyState=Bundle[mParcelledData.dataSize=272]}]
        I/RESTART(22759): (main) [3,3] Bundle[{android:viewHierarchyState=Bundle[mParcelledData.dataSize=272]}] || com.miga.podstars.PodstarsActivity@a8a2176 || true || 0
        I/RESTART(22759): (main) [1,4] Bundle[{android:viewHierarchyState=Bundle[mParcelledData.dataSize=272]}] || com.miga.podstars.PodstarsActivity@a8a2176 || true || 0
        I/RESTART start(22759): (main) [595,599] start
        I/TiRootActivity(22759): (main) [0,0] checkpoint, on root activity resume. activity = com.miga.podstars.PodstarsActivity@a8a2176
        I/RESTART resume(22759): (main) [0,0] resume
        I/RESTART base(22759): (main) [0,0] resume
        I/RESTART pause(22759): (main) [283,283] pause
        I/RESTART(22759): (main) [10,293] null || org.appcelerator.titanium.TiActivity@eee473f || false || 0
        D/Window(22759): Checkpoint: postWindowCreated()
        I/RESTART base(22759): (main) [58,373] resume
        I/RESTART CHECK(22759): (main) [471,844] base stop
        
        
  17. Gary Mathews 2017-02-22

    [~michael] Thanks for looking into this! I'll see what else I can find.
  18. Jason Priebe 2017-03-30

    Our apps have suffered for years from *exactly* the same behavior Michael G captured in his video. It has been a minor annoyance, since it usually resulted in a quick "flash", and then the app would start from splash screen. I think most users probably don't even know that anything bad has happened. It was just an aesthetic problem. Lately, however, android is popping up dialogs saying that the app has stopped, requiring the user to tap a "restart" button. I don't know if this is something that has happened in newer android versions (I see it on Nougat, and it seems like the problem started either with my phone updating to Nougat, or our app updating to Ti SDK version 6.x.x). This bug is extremely hard to reproduce, but if you use the app 4 or 5 times a day, it will happen at least every other day. It's just very hard to *make* it happen for debugging purposes. But it is *very* real, and if these restart dialogs can't be fixed, it will present a serious UX problem for our android users.
  19. Michael Gangolf 2017-03-30

    [~jpriebe] doesn't that "restart" dialog appear when the app is not responding (e.g. freezing, too much work): "app is not responding - wait / restart"? Or a different dialog? I'm not seeing that popup in my tests but I have the same problem that it is very hard to reproduce it and takes some time. About the restart: Not sure if you follow the Github PR: https://github.com/appcelerator/titanium_mobile/pull/8843 It's much better with the latest [bugfix](https://github.com/appcelerator/titanium_mobile/pull/8843#issuecomment-289566096)
  20. Jason Priebe 2017-03-30

    Michael - it's not happening during any freezing or hard work (we don't block the UI or do anything computationally intensive in our app anyway). This happens when the app is foregrounded (usually after it has been in the background for a while). I will try to screencap the dialog so you can see exactly what it says. I will look into the PR; thanks for the tip. BTW -- I tried to use the "user mention" feature of the comments editor, and it's not working for me. But you seem to be following this pretty closely.
  21. Michael Gangolf 2017-03-30

    The "user mention" button is wrong ;) It is
         [~username]
        
    Hope you can create a screenshot/-capture. And perhaps try a 6.1 nightly build to see if that works better. There are many useful patches (and the latest PR aren't even in yet)
  22. Jason Priebe 2017-04-03

    [~michael] - I got a screenshot. App had been in background for several hours. I opened the app, and I briefly saw the contents of the app, it crashed and restarted immediately. Saw the splash screen, and then it shut down again, presenting this dialog. !http://i.imgur.com/fYPZzb4.png! I didn't have access to a debugger at the time, so I don't have any logs, but I've looked at the logs in the past when this happens, and I haven't seen anything obvious. There's some information about Android N's crash handling [here](http://www.androidpolice.com/2016/03/10/android-n-feature-spotlight-new-force-close-pop-up-has-reset-and-restart-and-mute-until-device-restarts-options/). The article doesn't specifically say that the "restart app / send feedback" dialog is new in Android N, but I really feel like these dialogs only started coming up when I upgraded my phone to Nougat.
  23. Brian Knorr 2017-04-03

    This is exactly what is happening to all our users on Android 7.x+. I also see a pull request that is being blocked here https://github.com/appcelerator/titanium_mobile/pull/8843 When will this be in and can we get an emergency patch to Ti SDK 6.0.x? Here is the stack trace when users send the crash as feedback to Google Play
        *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
        Build fingerprint: 'Verizon/heroqltevzw/heroqltevzw:7.0/NRD90M/G930VVRU4BQA4:user/release-keys'
        Revision: '15'
        ABI: 'arm'
        pid: 22145, tid: 22145, name: ep.ylcommission  >>> com.starterstep.ylcommission <<<
        signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x0
            r0 00000000  r1 f0910000  r2 75646f4d  r3 0000656c
            r4 00000000  r5 d1d7edc8  r6 f20252a0  r7 00000000
            r8 00000000  r9 d1d7ad78  sl ffd007f4  fp f265b008
            ip 5f781400  sp ffd00740  lr d155afa3  pc d1639204  cpsr a0070010
        
        backtrace:
            #00 pc 003a7204  /data/app/com.starterstep.ylcommission-2/lib/arm/libkroll-v8.so (_ZN2v86Object3GetENS_5LocalINS_5ValueEEE+8)
            #01 pc 002c8f9f  /data/app/com.starterstep.ylcommission-2/lib/arm/libkroll-v8.so (Java_org_appcelerator_kroll_runtime_v8_V8Runtime_nativeRunModule+106)
            #02 pc 00b3e235  /data/app/com.starterstep.ylcommission-2/oat/arm/base.odex (offset 0xaa5000)
        
  24. Victor Vazquez Montero 2017-04-27

    [~gmathews] Hey Gary do we have any update on this ticket?
  25. Jason Priebe 2017-04-27

    BTW -- still happening with SDK version 6.0.3.
  26. Gary Mathews 2017-05-03

  27. Jason Priebe 2017-05-03

    [~gmathews] - I don't think that issue is the same as what I'm seeing. I see this happen all the time, and I've never once taken permissions away from the app while it was backgrounded. I built our app with 6.0.4 a couple of days ago; I will report back on what happens with 6.0.4. (btw - if you read the previous edit of this post, I *thought* I was running the app with 6.0.4, but apparently my phone did not have the build from a couple of days ago. I will install that now and see what happens).
  28. Jason Priebe 2017-05-08

    It might be too early to be sure, but so far, with 6.0.4, things seem better. Over the past few days, I have been launching our app, leaving it in the background for an hour or two, and then resuming it. Most importantly, I'm not getting the "app has stopped" dialogs, but even better, I'm not getting the quick "flash" of an auto-restart. I don't exactly understand how a fix for TIMOB-24265 could have fixed this, but initial results are certainly encouraging.
  29. Rene Pot 2018-03-14

    [~jpriebe] its been a year since you reported it might looked fixed. Can you still confirm it does?
  30. Jason Priebe 2018-03-14

    I have not seen this problem since 6.0.4.
  31. Joshua Quick 2019-04-11

    Titanium's app resume and intent handling has been rewritten by [TIMOB-26075] in of 8.0.0. This change will fix this issue. Closing.

JSON Source