GitHub Issue | n/a |
Type | Bug |
Priority | Critical |
Status | Closed |
Resolution | Cannot Reproduce |
Resolution Date | 2013-06-26T18:48:25.000+0000 |
Affected Version/s | Release 3.1.0 |
Fix Version/s | 2013 Sprint 13 Core, 2013 Sprint 13 |
Components | Android |
Labels | parity, triage |
Reporter | Daniel Sefton |
Assignee | Matt Langston |
Created | 2013-04-24T00:28:37.000+0000 |
Updated | 2017-03-21T21:36:09.000+0000 |
*Problem description*
Garbage collection is occurring when it shouldn't be on Android only (see test case). There could be a conflict between JavaScript and Java's garbage collection mechanisms.
*Steps to reproduce*
1. Run attached project on Android device
2. Tap "Click to get to screen"
3. Wait 20 (or more) seconds
4. Tap "Wait 20 seconds" button
5. Observe crash
*Test case*
See attached project.
Possible workaround: declaring 2DMatrix *outside* the View2 constructor doesn't cause crash. That way we can call the method without changing scope of the variable.
So right now, as per our understanding, only following scope causes the crash.
Second work around. Declare the 2DMatrix within the click handler and it will not crash. This is not limited to 2DMatrix. It has crashed on events, animations, etc.
Extra reproduction steps: 1. Tax the OS by opening a browser with lots of tabs. Open other apps. 2. Open the demo app 3. Wait a minute or two before clicking
04-26 11:00:12.330 143 288 D SurfaceFlinger: About to give-up screen, flinger = 0x412d1af0 04-26 11:00:15.659 308 357 I WindowManager: No lock screen! 04-26 11:00:15.760 9834 9834 I TiRootActivity: (main) [0,0] checkpoint, on root activity resume. activity = com.lanica.compositecrash.CompositecrashActivity@4136ec68 04-26 11:00:15.770 143 288 D SurfaceFlinger: Screen about to return, flinger = 0x412d1af0 04-26 11:00:18.180 9834 9849 F libc : Fatal signal 11 (SIGSEGV) at 0x0000000c (code=1), thread 9849 (KrollRuntimeThr) 04-26 11:00:18.280 142 142 I DEBUG : *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** 04-26 11:00:18.280 142 142 I DEBUG : Build fingerprint: 'motorola/tervigon/wingray:4.1.1/JRO03H/405518:user/release-keys' 04-26 11:00:18.280 142 142 I DEBUG : pid: 9834, tid: 9849, name: KrollRuntimeThr >>> com.lanica.compositecrash <<< 04-26 11:00:18.280 142 142 I DEBUG : signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0000000c 04-26 11:00:18.370 142 142 I DEBUG : r0 00000000 r1 5e2759a0 r2 000000aa r3 00000001 04-26 11:00:18.370 142 142 I DEBUG : r4 00000000 r5 5c524db8 r6 510f16fc r7 00000000 04-26 11:00:18.370 142 142 I DEBUG : r8 5ddf57ff r9 5c525418 sl 510f16fc fp 510f1700 04-26 11:00:18.370 142 142 I DEBUG : ip 5e33ef10 sp 5ddf5798 lr 5de65f5b pc 5de65d7c cpsr 400f0030 04-26 11:00:18.370 142 142 I DEBUG : d0 4083e80000000000 d1 bff000004326aaab 04-26 11:00:18.370 142 142 I DEBUG : d2 40f86a0000000000 d3 414e848000000000 04-26 11:00:18.370 142 142 I DEBUG : d4 4008000000000000 d5 4050800000000000 04-26 11:00:18.370 142 142 I DEBUG : d6 0000001d00000000 d7 0000001d00000000 04-26 11:00:18.370 142 142 I DEBUG : d8 0000000000000000 d9 0000000000000000 04-26 11:00:18.370 142 142 I DEBUG : d10 0000000000000000 d11 0000000000000000 04-26 11:00:18.370 142 142 I DEBUG : d12 0000000000000000 d13 0000000000000000 04-26 11:00:18.370 142 142 I DEBUG : d14 0000000000000000 d15 0000000000000000 04-26 11:00:18.370 142 142 I DEBUG : scr 60000011 04-26 11:00:18.380 142 142 I DEBUG : 04-26 11:00:18.380 142 142 I DEBUG : backtrace: 04-26 11:00:18.380 142 142 I DEBUG : #00 pc 0006fd7c /data/data/com.lanica.compositecrash/lib/libkroll-v8.so (titanium::EventEmitter::~EventEmitter()+71) 04-26 11:00:18.380 142 142 I DEBUG : #01 pc 0006ff57 /data/data/com.lanica.compositecrash/lib/libkroll-v8.so (titanium::JavaObject::getJavaObject()+58) 04-26 11:00:18.380 142 142 I DEBUG : #02 pc 000758f3 /data/data/com.lanica.compositecrash/lib/libkroll-v8.so (titanium::TypeConverter::jsValueToJavaObject(v8::Local
h....l..#c
F.. 04-26 11:00:18.380 142 142 I DEBUG : 5de65d6c 4620eb5a bf00bd70 004d90f4 000013bc Z. Fp.....M..... 04-26 11:00:18.380 142 142 I DEBUG : 5de65d7c b10b68c3 47707d00 2b006903 2001d1fa .h...}pG.i.+... 04-26 11:00:18.380 142 142 I DEBUG : 5de65d8c bf00e7f9 4604b510 b1114608 f0d44608 .......F.F...F.. 04-26 11:00:18.380 142 142 I DEBUG : 5de65d9c 6060e84a 46222100 ec4cf0c1 bf00bd10 J.`.!"F..L..... 04-26 11:00:18.380 142 142 I DEBUG : 04-26 11:00:18.380 142 142 I DEBUG : code around lr: 04-26 11:00:18.380 142 142 I DEBUG : 5de65f38 23004a11 46216860 447a7523 eb58f0bd .J.#
h!F#uzD..X. 04-26 11:00:18.380 142 142 I DEBUG : 5de65f48 6900e003 fe6cf004 46284605 f7ffbd70 ...i..l..F(Fp... 04-26 11:00:18.380 142 142 I DEBUG : 5de65f58 b908ff11 e7f868e5 21004620 ffc6f7ff .....h.. F.!.... 04-26 11:00:18.380 142 142 I DEBUG : 5de65f68 e7f268e5 20064905 44794a05 f7ff447a .h...I. .JyDzD.. 04-26 11:00:18.380 142 142 I DEBUG : 5de65f78 e7ddeac0 004da884 ffffff5b 003c586a ......M.[...jX<. 04-26 11:00:18.490 308 346 I BootReceiver: Copying /data/tombstones/tombstone_09 to DropBox (SYSTEM_TOMBSTONE) 04-26 11:00:18.510 308 361 W InputDispatcher: channel '41568260 com.lanica.compositecrash/com.lanica.compositecrash.CompositecrashActivity (server)' ~ Consumer closed input channel or an error occurred. events=0x9 04-26 11:00:18.510 308 361 E InputDispatcher: channel '41568260 com.lanica.compositecrash/com.lanica.compositecrash.CompositecrashActivity (server)' ~ Channel is unrecoverably broken and will be disposed! 04-26 11:00:18.510 144 144 D Zygote : Process 9834 terminated by signal (11) 04-26 11:00:18.550 308 346 D dalvikvm: GC_FOR_ALLOC freed 710K, 42% free 10008K/16963K, paused 48ms, total 49ms 04-26 11:00:18.550 308 361 W InputDispatcher: Attempted to unregister already unregistered input channel '41568260 com.lanica.compositecrash/com.lanica.compositecrash.CompositecrashActivity (server)' 04-26 11:00:18.550 308 731 I ActivityManager: Process com.lanica.compositecrash (pid 9834) has died. 04-26 11:00:18.550 308 361 I WindowManager: WINDOW DIED Window{41568260 com.lanica.compositecrash/com.lanica.compositecrash.CompositecrashActivity paused=false} 04-26 11:00:18.550 308 731 W ActivityManager: Force removing ActivityRecord{4165a270 com.lanica.compositecrash/.CompositecrashActivity}: app died, no saved state 04-26 11:00:18.550 308 758 W WindowManager: Failed looking up window 04-26 11:00:18.550 308 758 W WindowManager: java.lang.IllegalArgumentException: Requested window android.os.BinderProxy@416c8940 does not exist 04-26 11:00:18.550 308 758 W WindowManager: at com.android.server.wm.WindowManagerService.windowForClientLocked(WindowManagerService.java:7664) 04-26 11:00:18.550 308 758 W WindowManager: at com.android.server.wm.WindowManagerService.windowForClientLocked(WindowManagerService.java:7655) 04-26 11:00:18.550 308 758 W WindowManager: at com.android.server.wm.WindowState$DeathRecipient.binderDied(WindowState.java:854) 04-26 11:00:18.550 308 758 W WindowManager: at android.os.BinderProxy.sendDeathNotice(Binder.java:449) 04-26 11:00:18.550 308 758 W WindowManager: at dalvik.system.NativeStart.run(Native Method) 04-26 11:00:18.550 308 758 I WindowState: WIN DEATH: null 04-26 11:00:18.570 308 674 W InputMethodManagerService: Got RemoteException sending setActive(false) notification to pid 9834 uid 10053 04-26 11:00:20.690 1796 1796 D dalvikvm: WAIT_FOR_CONCURRENT_GC blocked 0ms 04-26 11:00:20.720 1796 1796 D dalvikvm: GC_EXPLICIT freed 96K, 70% free 5376K/17731K, paused 2ms+3ms, total 24ms ^[[AHi, We spent a whole day on this bug, and here is our conclusion.. The problem is about Javascript scope for Titanium objects. In the logs, the problem was clearly after a garbage collect, so, first of all, we created a small module called "androidgc" which simply launch Android garbage collector (not the V8 GC). You can find this module here : https://github.com/ChrOnOs83/TiModuleAndroidGC Then, we decided to use your files and made it as simple as possible. We finally got a unique app.js file with this content :
When you run this code on your Android Device, you should press many times on the "GC" button, because garbage collector may not clean your ressources each time... If GC has be done correctly, the second button press will fail, because the label is not here anymore. If you add the label to the view, and then change its title, no problem If you create the label in the event listener, no problem *If you makes a reference to a global variable (without the _var_ keyword for example), it works* If you put the function in a CommonJS module, the same rules apply. So... Titanium objects created in a function (all the Ti.something) may be killed by garbage collector at any time if they are not attached to a view/window, or declared as global var. It breaks the Javascript scope pattern...
And the problem exists also in SDK 2.3 and 3.0
Marking as cannot reproduce for the original test case.
Closing ticket as the issue cannot be reproduced and due to the above comments.