{ "id": "152871", "key": "TIMOB-19903", "fields": { "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false }, "project": { "id": "10153", "key": "TIMOB", "name": "Titanium SDK/CLI", "projectCategory": { "id": "10100", "description": "Titanium and related SDKs used in application development", "name": "Client" } }, "fixVersions": [ { "id": "17706", "name": "Release 5.4.0", "archived": false, "released": true, "releaseDate": "2016-08-11" } ], "resolution": { "id": "1", "description": "A fix for this issue is checked into the tree and tested.", "name": "Fixed" }, "resolutiondate": "2015-11-24T20:22:46.000+0000", "created": "2015-11-10T14:49:39.000+0000", "epic": { "id": 151897, "key": "TIMOB-19699", "name": "Android: Hyperloop for Android module", "summary": "Bring Hyperloop to Android", "color": { "key": "color_4" }, "done": false }, "priority": { "name": "Critical", "id": "1" }, "labels": [], "versions": [], "issuelinks": [ { "id": "49797", "type": { "id": "10001", "name": "Cloners", "inward": "is cloned into", "outward": "is cloned from" }, "inwardIssue": { "id": "153128", "key": "TIMOB-19994", "fields": { "summary": "Android: Fix memory leaks in UI proxies", "status": { "description": "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.", "name": "Closed", "id": "6", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "priority": { "name": "Critical", "id": "1" }, "issuetype": { "id": "7", "description": "gh.issue.story.desc", "name": "Story", "subtask": false } } } } ], "assignee": { "name": "cwilliams", "key": "cwilliams", "displayName": "Christopher Williams", "active": true, "timeZone": "America/New_York" }, "updated": "2016-07-28T22:20:56.000+0000", "status": { "description": "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.", "name": "Closed", "id": "6", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "components": [ { "id": "10202", "name": "Android", "description": "Android Platform" }, { "id": "13715", "name": "Hyperloop", "description": "Hyperloop project" } ], "description": "If we generate a native UI proxy (say an android.view.View) and add it to a Titanium UI, we see crashes when the UI is GCed. This can bee easily seen in the hyperloop-examples repo. Once we go to an example where we generate a native view and add it to the UI from Titanium (like say Animate View example) and then go back to the main listing - causing a GC of the elements in that view, we see a crash of the app.", "attachment": [], "flagged": false, "summary": "Android: Fix crash due to GC of UI native proxies in hyperloop", "creator": { "name": "cwilliams", "key": "cwilliams", "displayName": "Christopher Williams", "active": true, "timeZone": "America/New_York" }, "subtasks": [], "reporter": { "name": "cwilliams", "key": "cwilliams", "displayName": "Christopher Williams", "active": true, "timeZone": "America/New_York" }, "environment": null, "comment": { "comments": [ { "id": "370218", "author": { "name": "cwilliams", "key": "cwilliams", "displayName": "Christopher Williams", "active": true, "timeZone": "America/New_York" }, "body": "Finally managed to get a run with a debug build of the SDk so I can get real info:\r\n{code}\r\n*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***\r\nBuild fingerprint: 'generic_x86_64/sdk_google_phone_x86_64/generic_x86_64:6.0/MASTER/2401146:eng/test-keys'\r\nRevision: '0'\r\nABI: 'x86'\r\npid: 2750, tid: 2750, name: ample.hyperloop >>> com.appcelerator.sample.hyperloop <<<\r\nsignal 6 (SIGABRT), code -6 (SI_TKILL), fault addr --------\r\nAbort message: 'src/native/NativeObject.h:36: virtual titanium::NativeObject::~NativeObject(): assertion \"handle_.IsNearDeath()\" failed'\r\n eax 00000000 ebx 00000abe ecx 00000abe edx 00000006\r\n esi f776dc50 edi 0000000b\r\n xcs 00000023 xds 0000002b xes 0000002b xfs 00000007 xss 0000002b\r\n eip f7338e06 ebp 00000abe esp ff9c6ab0 flags 00200206\r\n\r\nbacktrace:\r\n #00 pc 00085e06 /system/lib/libc.so (tgkill+22)\r\n #01 pc 00082468 /system/lib/libc.so (pthread_kill+70)\r\n #02 pc 000280a5 /system/lib/libc.so (raise+36)\r\n #03 pc 0002187d /system/lib/libc.so (abort+80)\r\n #04 pc 000255e1 /system/lib/libc.so (__libc_fatal+32)\r\n #05 pc 000219fc /system/lib/libc.so (__assert2+60)\r\n #06 pc 0008e1e3 /data/app/com.appcelerator.sample.hyperloop-1/lib/x86/libkroll-v8.so (titanium::NativeObject::~NativeObject()+117)\r\n #07 pc 0008e675 /data/app/com.appcelerator.sample.hyperloop-1/lib/x86/libkroll-v8.so (titanium::EventEmitter::~EventEmitter()+43)\r\n #08 pc 00090f74 /data/app/com.appcelerator.sample.hyperloop-1/lib/x86/libkroll-v8.so (titanium::JavaObject::~JavaObject()+74)\r\n #09 pc 0009c689 /data/app/com.appcelerator.sample.hyperloop-1/lib/x86/libkroll-v8.so (titanium::Proxy::~Proxy()+43)\r\n #10 pc 0009c6c3 /data/app/com.appcelerator.sample.hyperloop-1/lib/x86/libkroll-v8.so (titanium::Proxy::~Proxy()+29)\r\n #11 pc 000a3b0e /data/app/com.appcelerator.sample.hyperloop-1/lib/x86/libkroll-v8.so (Java_org_appcelerator_kroll_runtime_v8_V8Object_nativeRelease+165)\r\n #12 pc 01187c76 /data/app/com.appcelerator.sample.hyperloop-1/oat/x86/base.odex (offset 0xce3000)\r\n\r\nstack:\r\n ff9c6a70 00000010\r\n ff9c6a74 ff9c6b40 [stack]\r\n ff9c6a78 00000010\r\n ff9c6a7c 00000000\r\n ff9c6a80 f7335390 /system/lib/libc.so (pthread_getspecific+7)\r\n ff9c6a84 00000000\r\n ff9c6a88 00570000\r\n ff9c6a8c f73ac71c /system/lib/libc.so\r\n ff9c6a90 f776dc00 /system/bin/linker\r\n ff9c6a94 f73b2c90\r\n ff9c6a98 ff9c6bb8 [stack]\r\n ff9c6a9c f7335101 /system/lib/libc.so (__pthread_internal_find(long)+65)\r\n ff9c6aa0 f73b2c90\r\n ff9c6aa4 ff9c6ab0 [stack]\r\n ff9c6aa8 ff9c6ab8 [stack]\r\n ff9c6aac 00000008\r\n #00 ff9c6ab0 00000006\r\n ff9c6ab4 00000002\r\n ff9c6ab8 f73ac71c /system/lib/libc.so\r\n ff9c6abc f7335469 /system/lib/libc.so (pthread_kill+71)\r\n #01 ff9c6ac0 00000abe\r\n ff9c6ac4 00000abe\r\n ff9c6ac8 00000006\r\n ff9c6acc f77723a9 /system/bin/app_process32 (sigprocmask+141)\r\n ff9c6ad0 00000002\r\n ff9c6ad4 ff9c6aec [stack]\r\n ff9c6ad8 00000000\r\n ff9c6adc f73ac71c /system/lib/libc.so\r\n ff9c6ae0 ff9c6b2c [stack]\r\n ff9c6ae4 12dd5040 /dev/ashmem/dalvik-main space (deleted)\r\n ff9c6ae8 ff9c6bb8 [stack]\r\n ff9c6aec f72db0a6 /system/lib/libc.so (raise+37)\r\n #02 ff9c6af0 f776dc00 /system/bin/linker\r\n ff9c6af4 00000006\r\n ff9c6af8 ff9c6b78 [stack]\r\n ff9c6afc f73ac71c /system/lib/libc.so\r\n ff9c6b00 ff9c6b2c [stack]\r\n ff9c6b04 f73ac71c /system/lib/libc.so\r\n ff9c6b08 ff9c6b2c [stack]\r\n ff9c6b0c f72d487e /system/lib/libc.so (abort+81)\r\n #03 ff9c6b10 00000006\r\n ff9c6b14 ff9c6b2c [stack]\r\n ff9c6b18 00000000\r\n ff9c6b1c 00000009\r\n ff9c6b20 f7335390 /system/lib/libc.so (pthread_getspecific+7)\r\n ff9c6b24 e159cdd0 /data/app/com.appcelerator.sample.hyperloop-1/lib/x86/libkroll-v8.so\r\n ff9c6b28 1308f1c0 /dev/ashmem/dalvik-main space (deleted)\r\n ff9c6b2c ffffffdf\r\n ff9c6b30 80000016\r\n ff9c6b34 ff9c6b68 [stack]\r\n ff9c6b38 00000000\r\n ff9c6b3c f73ac71c /system/lib/libc.so\r\n ff9c6b40 f73ac71c /system/lib/libc.so\r\n ff9c6b44 1308f1c0 /dev/ashmem/dalvik-main space (deleted)\r\n ff9c6b48 12dd5040 /dev/ashmem/dalvik-main space (deleted)\r\n ff9c6b4c f72d85e2 /system/lib/libc.so (__fortify_chk_fail)\r\n #04 ff9c6b50 ebaa7930 [anon:libc_malloc]\r\n ff9c6b54 0010050a\r\n ff9c6b58 f73ac71c /system/lib/libc.so\r\n ff9c6b5c f72d49fd /system/lib/libc.so (atof)\r\n #05 ff9c6b60 f7383094 /system/lib/libc.so\r\n ff9c6b64 e144b876 /data/app/com.appcelerator.sample.hyperloop-1/lib/x86/libkroll-v8.so\r\n ff9c6b68 00000024\r\n ff9c6b6c e144ba60 /data/app/com.appcelerator.sample.hyperloop-1/lib/x86/libkroll-v8.so\r\n ff9c6b70 e144b860 /data/app/com.appcelerator.sample.hyperloop-1/lib/x86/libkroll-v8.so\r\n ff9c6b74 e159cdd0 /data/app/com.appcelerator.sample.hyperloop-1/lib/x86/libkroll-v8.so\r\n ff9c6b78 ff9c6ba8 [stack]\r\n ff9c6b7c e0f09d8d /data/app/com.appcelerator.sample.hyperloop-1/lib/x86/libkroll-v8.so (titanium::ReferenceTable::destroyReference(int)+69)\r\n ff9c6b80 f4019ae0 [anon:libc_malloc]\r\n ff9c6b84 e159cdd0 /data/app/com.appcelerator.sample.hyperloop-1/lib/x86/libkroll-v8.so\r\n ff9c6b88 e159cdd0 /data/app/com.appcelerator.sample.hyperloop-1/lib/x86/libkroll-v8.so\r\n ff9c6b8c e0ef91e4 /data/app/com.appcelerator.sample.hyperloop-1/lib/x86/libkroll-v8.so (titanium::NativeObject::~NativeObject()+118)\r\n #06 ff9c6b90 e144b876 /data/app/com.appcelerator.sample.hyperloop-1/lib/x86/libkroll-v8.so\r\n ff9c6b94 00000024\r\n ff9c6b98 e144ba60 /data/app/com.appcelerator.sample.hyperloop-1/lib/x86/libkroll-v8.so\r\n ff9c6b9c e144b860 /data/app/com.appcelerator.sample.hyperloop-1/lib/x86/libkroll-v8.so\r\n ff9c6ba0 80000016\r\n ff9c6ba4 e159cdd0 /data/app/com.appcelerator.sample.hyperloop-1/lib/x86/libkroll-v8.so\r\n ff9c6ba8 ff9c6bd8 [stack]\r\n ff9c6bac e0efbf19 /data/app/com.appcelerator.sample.hyperloop-1/lib/x86/libkroll-v8.so (titanium::JavaObject::deleteGlobalRef()+121)\r\n ff9c6bb0 0000004f\r\n ff9c6bb4 e159cdd0 /data/app/com.appcelerator.sample.hyperloop-1/lib/x86/libkroll-v8.so\r\n ff9c6bb8 ff9c6bd8 [stack]\r\n ff9c6bbc e0ef9676 /data/app/com.appcelerator.sample.hyperloop-1/lib/x86/libkroll-v8.so (titanium::EventEmitter::~EventEmitter()+44)\r\n #07 ff9c6bc0 e01bd860 [anon:libc_malloc]\r\n ff9c6bc4 e01bd860 [anon:libc_malloc]\r\n ff9c6bc8 ff9c6be8 [stack]\r\n ff9c6bcc f4019ae0 [anon:libc_malloc]\r\n ff9c6bd0 e01bd860 [anon:libc_malloc]\r\n ff9c6bd4 e159cdd0 /data/app/com.appcelerator.sample.hyperloop-1/lib/x86/libkroll-v8.so\r\n ff9c6bd8 ff9c6bf8 [stack]\r\n ff9c6bdc e0efbf75 /data/app/com.appcelerator.sample.hyperloop-1/lib/x86/libkroll-v8.so (titanium::JavaObject::~JavaObject()+75)\r\n #08 ff9c6be0 e01bd860 [anon:libc_malloc]\r\n ff9c6be4 e159cdd0 /data/app/com.appcelerator.sample.hyperloop-1/lib/x86/libkroll-v8.so\r\n ff9c6be8 ff9c6c18 [stack]\r\n ff9c6bec e0f051f2 /data/app/com.appcelerator.sample.hyperloop-1/lib/x86/libkroll-v8.so (v8::Object::GetPointerFromInternalField(int)+94)\r\n ff9c6bf0 e01bd860 [anon:libc_malloc]\r\n ff9c6bf4 e159cdd0 /data/app/com.appcelerator.sample.hyperloop-1/lib/x86/libkroll-v8.so\r\n ff9c6bf8 ff9c6c18 [stack]\r\n ff9c6bfc e0f0768a /data/app/com.appcelerator.sample.hyperloop-1/lib/x86/libkroll-v8.so (titanium::Proxy::~Proxy()+44)\r\n #09 ff9c6c00 e01bd860 [anon:libc_malloc]\r\n ff9c6c04 5cf1a4f5\r\n ff9c6c08 0000000c\r\n ff9c6c0c e01bd860 [anon:libc_malloc]\r\n ff9c6c10 80000016\r\n ff9c6c14 e159cdd0 /data/app/com.appcelerator.sample.hyperloop-1/lib/x86/libkroll-v8.so\r\n ff9c6c18 ff9c6c38 [stack]\r\n ff9c6c1c e0f076c4 /data/app/com.appcelerator.sample.hyperloop-1/lib/x86/libkroll-v8.so (titanium::Proxy::~Proxy()+30)\r\n #10 ff9c6c20 e01bd860 [anon:libc_malloc]\r\n ff9c6c24 00000000\r\n ff9c6c28 f3f85070 [anon:libc_malloc]\r\n ff9c6c2c e159cdd0 /data/app/com.appcelerator.sample.hyperloop-1/lib/x86/libkroll-v8.so\r\n ff9c6c30 1308f1c0 /dev/ashmem/dalvik-main space (deleted)\r\n ff9c6c34 e159cdd0 /data/app/com.appcelerator.sample.hyperloop-1/lib/x86/libkroll-v8.so\r\n ff9c6c38 ff9c6c78 [stack]\r\n ff9c6c3c e0f0eb0f /data/app/com.appcelerator.sample.hyperloop-1/lib/x86/libkroll-v8.so (Java_org_appcelerator_kroll_runtime_v8_V8Object_nativeRelease+166)\r\n #11 ff9c6c40 e01bd860 [anon:libc_malloc]\r\n ff9c6c44 ebaa7930 [anon:libc_malloc]\r\n ff9c6c48 ebaa7930 [anon:libc_malloc]\r\n ff9c6c4c ffffffff\r\n ff9c6c50 00000000\r\n ff9c6c54 00000000\r\n ff9c6c58 ebaa7930 [anon:libc_malloc]\r\n ff9c6c5c e01bd860 [anon:libc_malloc]\r\n ff9c6c60 f3262000 [anon:libc_malloc]\r\n ff9c6c64 00000000\r\n ff9c6c68 00000000\r\n ff9c6c6c ffffff00\r\n ff9c6c70 ffffffff\r\n ff9c6c74 1308f1c0 /dev/ashmem/dalvik-main space (deleted)\r\n ff9c6c78 1308f1c0 /dev/ashmem/dalvik-main space (deleted)\r\n ff9c6c7c e3b95c77 /data/app/com.appcelerator.sample.hyperloop-1/oat/x86/base.odex\r\n #12 ff9c6c80 f4019ae0 [anon:libc_malloc]\r\n ff9c6c84 ff9c6cac [stack]\r\n ff9c6c88 ebaa7930 [anon:libc_malloc]\r\n ff9c6c8c ffffffff\r\n ff9c6c90 f4034500 [anon:libc_malloc]\r\n ff9c6c94 12c77580 /dev/ashmem/dalvik-main space (deleted)\r\n ff9c6c98 73587bc0 /data/dalvik-cache/x86/system@framework@boot.oat\r\n ff9c6c9c f3955d6a /system/lib/libart.so (art::JniMethodEnd(unsigned int, art::Thread*)+15)\r\n ff9c6ca0 f0e55460 /dev/ashmem/dalvik-LinearAlloc (deleted)\r\n ff9c6ca4 ff9c7004 [stack]\r\n ff9c6ca8 00000001\r\n ff9c6cac 12db4e00 /dev/ashmem/dalvik-main space (deleted)\r\n ff9c6cb0 00000006\r\n ff9c6cb4 f4034500 [anon:libc_malloc]\r\n ff9c6cb8 00000000\r\n ff9c6cbc 00000000\r\n{code}", "updateAuthor": { "name": "cwilliams", "key": "cwilliams", "displayName": "Christopher Williams", "active": true, "timeZone": "America/New_York" }, "created": "2015-11-13T17:10:15.000+0000", "updated": "2015-11-13T17:10:15.000+0000" }, { "id": "370240", "author": { "name": "cwilliams", "key": "cwilliams", "displayName": "Christopher Williams", "active": true, "timeZone": "America/New_York" }, "body": "Ok, so after a lot of looking at this, I finally nailed the crashes to coming from trying to release an ActivityProxy when we close a Window:\r\n{code}\r\n11-13 14:28:55.810 2462 2502 D OpenGLRenderer: endAllStagingAnimators on 0xe0911700 (RippleDrawable) with handle 0xe00ff1d0\r\n11-13 14:28:56.200 2462 2462 D TiViewProxy: (main) [55530,55530] Releasing views for: ti.modules.titanium.ui.WindowProxy@773e779\r\n11-13 14:28:56.200 2462 2462 D TiViewProxy: (main) [0,55530] Releasing views for: ti.modules.titanium.ui.ScrollViewProxy@d769cbe\r\n11-13 14:28:56.200 2462 2462 D TiViewProxy: (main) [0,55530] Releasing views for: ti.modules.titanium.ui.ViewProxy@836d11f\r\n11-13 14:28:56.200 2462 2462 D TiViewProxy: (main) [0,55530] Releasing views for: hyperloop.InstanceProxy@8ac6c\r\n11-13 14:28:56.200 2462 2462 D TiViewProxy: (main) [0,55530] Releasing views for: ti.modules.titanium.ui.ButtonProxy@c1956d4\r\n11-13 14:28:56.200 2462 2462 D TiViewProxy: (main) [0,55530] Releasing views for: ti.modules.titanium.ui.LabelProxy@fc28235\r\n11-13 14:28:56.200 2462 2462 D Window : Window is closed normally.\r\n11-13 14:28:56.200 2462 2462 D KrollProxy: (main) [0,55530] Releasing : org.appcelerator.titanium.proxy.ActivityProxy@37bc6ca\r\n--------- beginning of crash\r\n{code}\r\n\r\nHere's what I think is happening: Our native hyperloop UI views are getting passed in a wrapped version of the current activity. We're not fully cleaning up all of our hyperloop proxies when the window closes - we're just getting the one call to release the views of the top-level ViewGroup we've added into our Ti.UI.View hierarchy. That HyperloopView is blissfully unaware of how to handle releasing all the children. We need to implement some system specifically for UI elements where we track children of a View and release the hyperloop proxies that correspond to all of them.", "updateAuthor": { "name": "cwilliams", "key": "cwilliams", "displayName": "Christopher Williams", "active": true, "timeZone": "America/New_York" }, "created": "2015-11-13T20:00:59.000+0000", "updated": "2015-11-13T20:00:59.000+0000" }, { "id": "370250", "author": { "name": "cwilliams", "key": "cwilliams", "displayName": "Christopher Williams", "active": true, "timeZone": "America/New_York" }, "body": "Ok, so it _does_ look like we have some sort of memory leak regarding the view hierarchy, so that needs to be fixed _but_ that's not the cause of the crash. I can reliably reproduce with a simple example that _doesn't_ use hyperloop and only happens when running on main thread:\r\n{code:javascript}\r\n// Window 1\r\nvar win1 = Ti.UI.createWindow();\r\nvar view1 = Ti.UI.createView();\r\nvar label1 = Ti.UI.createLabel({\r\n\ttext: \"Label 1\"\r\n});\r\nvar button1 = Ti.UI.createButton({\r\n\ttitle: \"Open another Window\"\r\n});\r\n\r\n// Window 2\r\nvar win2 = Ti.UI.createWindow();\r\nvar view2 = Ti.UI.createView();\r\nvar label2 = Ti.UI.createLabel({\r\n\ttext: \"Label 2\"\r\n});\r\nvar button2 = Ti.UI.createButton({\r\n\ttitle: \"Close this window\"\r\n});\r\n\r\nview1.add(label1);\r\nview1.add(button1);\r\nwin1.add(view1);\r\nwin1.open();\r\n\r\nview2.add(label2);\r\nview2.add(button2);\r\nwin2.add(view2);\r\n\r\nbutton2.addEventListener('click', function() {\r\n\twin2.close();\r\n});\r\n\r\nbutton1.addEventListener('click', function() {\r\n\twin2.open();\r\n});\r\n\r\nwin1.open();\r\n{code}\r\n\r\nWhen you close the second window, it will reliably crash only if run from the UI thread.", "updateAuthor": { "name": "cwilliams", "key": "cwilliams", "displayName": "Christopher Williams", "active": true, "timeZone": "America/New_York" }, "created": "2015-11-13T21:34:12.000+0000", "updated": "2015-11-13T21:34:12.000+0000" }, { "id": "370350", "author": { "name": "cwilliams", "key": "cwilliams", "displayName": "Christopher Williams", "active": true, "timeZone": "America/New_York" }, "body": "https://github.com/appcelerator/titanium_mobile/pull/7448", "updateAuthor": { "name": "cwilliams", "key": "cwilliams", "displayName": "Christopher Williams", "active": true, "timeZone": "America/New_York" }, "created": "2015-11-16T15:51:03.000+0000", "updated": "2015-11-16T15:51:03.000+0000" }, { "id": "391906", "author": { "name": "lchoudhary", "key": "lchoudhary", "displayName": "Lokesh Choudhary", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Verified the fix.\r\n\r\nVerified using the hyperloop sample app & the code above & running on main thread.\r\nNo crash seen.\r\n\r\nClosing.\r\n\r\nEnvironment:\r\nAppc Studio : 4.7.0.201607111053\r\nTi SDK : 5.4.0.v20160727143921\r\nTi CLI : 5.0.9\r\nAlloy : 1.9.1\r\nMAC El Capitan : 10.11.5\r\nAppc NPM : 4.2.8-1\r\nAppc CLI : 5.4.0-34\r\nNode: 4.4.4\r\nNexus 5X - Android 6.0.1", "updateAuthor": { "name": "lchoudhary", "key": "lchoudhary", "displayName": "Lokesh Choudhary", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2016-07-28T22:20:48.000+0000", "updated": "2016-07-28T22:20:48.000+0000" } ], "maxResults": 5, "total": 5, "startAt": 0 } } }