Problem
Assume we have a heavyweight window, and a service with START_REDELIVER_INTENT. If the app is closed (for low memory, or any other reason), and the service is restarted by the OS, launching the app shows only a black screen.
What's Worse
Because heavyweight/lightweight is being antiquated, and every window will now be heavyweight, the latest master builds exhibit this problem on every window. Using older versions of the SDK (3.1.3.GA), making the window lightweight would avoid this issue, somewhat, but properties like exitOnClose don't work properly.
Example
Follow the 4 steps in the app to reproduce this.
{panel:title=app.js}
// Make a window.
var win = Ti.UI.createWindow({
backgroundColor: 'white'
});
win.add(Ti.UI.createLabel({
text: 'Great! Please:' +
'\n' +
'1) press the home button,\n' +
'2) force-close the app,\n' +
'3) watch the logs for the service to restart itself,\n' +
'4) then try to launch the app again (it should be black).',
left: 20, right: 20
}));
win.open();
// Start an interval service.
var intent = Ti.Android.createServiceIntent({
url: 'service.js',
startMode: Ti.Android.START_REDELIVER_INTENT
});
intent.putExtra('interval', 1000);
Ti.Android.startService(intent);
{panel}
{panel:title=service.js}
console.log('Hello from service.js!');
{panel}
{panel:title=tiapp.xml}
<android xmlns:android="http://schemas.android.com/apk/res/android">
<services>
<service type="interval" url="service.js"/>
</services>
<manifest android:versionCode="100" android:versionName="1.0.0"/>
</android>
{panel}
Console
10-24 21:47:32.388: I/TiAPI(3555): Hello from service.js!
10-24 21:47:32.450: I/TiAPI(3555): Hello from service.js!
10-24 21:47:32.794: I/AndroidRuntime(3555): VM exiting with result code 1, cleanup skipped.
10-24 21:47:32.841: I/WindowState(409): WIN DEATH: Window{413aa378 u0 com.dawson.plays/org.appcelerator.titanium.TiActivity}
10-24 21:47:32.841: I/ActivityManager(409): Process com.dawson.plays (pid 3555) has died.
10-24 21:47:32.845: W/ActivityManager(409): Scheduling restart of crashed service com.dawson.plays/.ServiceService in 12318ms
10-24 21:47:32.845: I/WindowState(409): WIN DEATH: Window{40ff1ac0 u0 com.dawson.plays/com.dawson.plays.PlayActivity}
10-24 21:47:32.849: D/Zygote(148): Process 3555 exited cleanly (1)
10-24 21:47:34.236: D/lights(409): set_light_keyboard: color=0xff000000, klc=2.
10-24 21:47:34.240: D/lights(409): set_light_buttons: color=0xff000000, tlc=0.
10-24 21:47:45.240: I/ActivityManager(409): Start proc com.dawson.plays for service com.dawson.plays/.ServiceService: pid=3580 uid=10052 gids={50052, 1015, 3003, 1028}
10-24 21:47:45.255: I/dalvikvm(3580): Turning on JNI app bug workarounds for target SDK version 10...
10-24 21:47:45.286: I/TiApplication(3580): (main) [0,0] checkpoint, app created.
10-24 21:47:45.322: I/TiApplication(3580): (main) [34,34] Titanium 3.2.0 (2013/10/24 12:09 9b2cd09)
10-24 21:47:45.376: I/TiApplication(3580): (main) [57,91] Titanium Javascript runtime: v8
10-24 21:47:45.380: D/dalvikvm(3580): Trying to load lib /data/app-lib/com.dawson.plays-1/libstlport_shared.so 0x40e83198
10-24 21:47:45.384: D/dalvikvm(3580): Added shared lib /data/app-lib/com.dawson.plays-1/libstlport_shared.so 0x40e83198
10-24 21:47:45.384: D/dalvikvm(3580): No JNI_OnLoad found in /data/app-lib/com.dawson.plays-1/libstlport_shared.so 0x40e83198, skipping init
10-24 21:47:45.384: D/dalvikvm(3580): Trying to load lib /data/app-lib/com.dawson.plays-1/libkroll-v8.so 0x40e83198
10-24 21:47:45.392: D/dalvikvm(3580): Added shared lib /data/app-lib/com.dawson.plays-1/libkroll-v8.so 0x40e83198
10-24 21:47:45.603: W/V8Object(3580): Runtime disposed, cannot set property 'userAgent'
10-24 21:47:45.685: I/TiAPI(3580): Hello from service.js!
10-24 21:47:45.693: I/TiAPI(3580): Hello from service.js!
10-24 21:47:46.697: I/TiAPI(3580): Hello from service.js!
10-24 21:47:46.728: I/TiAPI(3580): Hello from service.js!
10-24 21:47:47.700: I/TiAPI(3580): Hello from service.js!
10-24 21:47:47.732: I/TiAPI(3580): Hello from service.js!
10-24 21:47:47.935: D/lights(409): set_light_keyboard: color=0xff0a0a0a, klc=1.
10-24 21:47:47.943: D/lights(409): set_light_buttons: color=0xff0a0a0a, tlc=1.
10-24 21:47:47.978: D/dalvikvm(590): GC_CONCURRENT freed 622K, 41% free 4495K/7592K, paused 2ms+4ms, total 39ms
10-24 21:47:47.978: D/dalvikvm(590): WAIT_FOR_CONCURRENT_GC blocked 33ms
10-24 21:47:48.146: I/ActivityManager(409): START u0 {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.dawson.plays/.PlayActivity bnds=[120,405][240,555]} from pid 590
10-24 21:47:48.376: V/PhoneStatusBar(494): setLightsOn(true)
10-24 21:47:48.427: I/ActivityManager(409): Displayed com.dawson.plays/org.appcelerator.titanium.TiActivity: +247ms
10-24 21:47:48.712: I/TiAPI(3580): Hello from service.js!
10-24 21:47:48.716: I/TiAPI(3580): Hello from service.js!
10-24 21:47:49.697: I/TiAPI(3580): Hello from service.js!
10-24 21:47:49.728: I/TiAPI(3580): Hello from service.js!
10-24 21:47:50.697: I/TiAPI(3580): Hello from service.js!
I can't reproduce this issue, even on 3.1.3.GA. I killed the app, waited for the service to restart, and the launched the app again, and I don't see a black screen. I did notice that there are two instances of the service running.
Did you try with the latest master? Do you have
Just tried this on master, without the setting the useLegacyWindow flag, and a clean build. I could not reproduce the issue. Maybe there is something special in your project? Could you attach a project that shows this behavior?
Closing ticket as the issue cannot be reproduced.