{ "id": "60906", "key": "TIMOB-274", "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": "11217", "name": "Release 0.8.1", "archived": true, "released": true, "releaseDate": "2009-12-07" } ], "resolution": { "id": "1", "description": "A fix for this issue is checked into the tree and tested.", "name": "Fixed" }, "resolutiondate": "2011-04-17T01:52:34.000+0000", "created": "2011-04-15T02:26:30.000+0000", "priority": { "name": "Medium", "id": "3" }, "labels": [ "android", "defect" ], "versions": [], "issuelinks": [], "assignee": { "name": "dthorp", "key": "dthorp", "displayName": "Don Thorp", "active": true, "timeZone": "America/Los_Angeles" }, "updated": "2011-04-17T01:52:34.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" } ], "description": "{html}

This works fine in iPhone simulator but not in Android, the page\nfirst loads fine but when I click on the button2, the application\nwould quit. If I comment out one line (\ncompositeView.addView(views[0],{left:0,top:5,height:30}); ) then it\nworks even if I add the webview.
\ncode:

\n
\nvar button2 = Titanium.UI.createButton({\n            id:'button2',\n            title:'Text'\n        });\n        button2.addEventListener('click',function(e)\n        {\n            webView = Titanium.UI.createWebView({url:'meters-text.html', name:'myview'});\n            var views = Titanium.UI.currentWindow.getViews();\n            var compositeView = Titanium.UI.createCompositeView();\n            compositeView.addView(views[0],{left:0,top:5,height:30}); // emulator quits here\n            compositeView.addView(webView,{top:40,left:0});\n            Titanium.UI.currentWindow.addView(compositeView);\n            Titanium.UI.currentWindow.showView(compositeView);\n        })\n
\n
\nLog shows the following:\n[TRACE] W/dalvikvm( 1433): JNI WARNING: JNI method called with exception raised\n[TRACE] W/dalvikvm( 1433): in Landroid/webkit/BrowserFrame;.stringByEvaluatingJavaScriptFromString (Ljava/lang/String;)Ljava/lang/String; (GetObjectClass)\n[TRACE] W/dalvikvm( 1433): Pending exception is:\n[TRACE] I/dalvikvm( 1433): Landroid/view/ViewRoot$CalledFromWrongThreadException;: Only the original thread that created a view hierarchy can touch its views.\n[TRACE] I/dalvikvm( 1433): at android.view.ViewRoot.checkThread(ViewRoot.java:2440)\n[TRACE] I/dalvikvm( 1433): at android.view.ViewRoot.requestLayout(ViewRoot.java:509)\n[TRACE] I/dalvikvm( 1433): at android.view.View.requestLayout(View.java:7069)\n[TRACE] I/dalvikvm( 1433): at android.view.View.setLayoutParams(View.java:4327)\n[TRACE] I/dalvikvm( 1433): at org.appcelerator.titanium.module.ui.TitaniumCompositeView.addView(TitaniumCompositeView.java:120)\n[TRACE] I/dalvikvm( 1433): at android.webkit.BrowserFrame.stringByEvaluatingJavaScriptFromString(Native Method)\n[TRACE] I/dalvikvm( 1433): at android.webkit.BrowserFrame.stringByEvaluatingJavaScriptFromString(Native Method)\n[TRACE] I/dalvikvm( 1433): at android.webkit.BrowserFrame.loadUrl(BrowserFrame.java:138)\n[TRACE] I/dalvikvm( 1433): at android.webkit.WebViewCore.loadUrl(WebViewCore.java:1174)\n[TRACE] I/dalvikvm( 1433): at android.webkit.WebViewCore.access$900(WebViewCore.java:42)\n[TRACE] I/dalvikvm( 1433): at android.webkit.WebViewCore$EventHub$1.handleMessage(WebViewCore.java:663)\n[TRACE] I/dalvikvm( 1433): at android.os.Handler.dispatchMessage(Handler.java:99)\n[TRACE] I/dalvikvm( 1433): at android.os.Looper.loop(Looper.java:123)\n[TRACE] I/dalvikvm( 1433): at android.webkit.WebViewCore$WebCoreThread.run(WebViewCore.java:462)\n[TRACE] I/dalvikvm( 1433): at java.lang.Thread.run(Thread.java:1058)\n[TRACE] I/dalvikvm( 1433): \"WebViewCoreThread\" prio=5 tid=17 NATIVE\n[TRACE] I/dalvikvm( 1433): | group=\"main\" sCount=0 dsCount=0 s=0 obj=0x4365a890\n[TRACE] I/dalvikvm( 1433): | sysTid=1444 nice=0 sched=0/0 handle=1750584\n[TRACE] I/dalvikvm( 1433): at android.webkit.BrowserFrame.stringByEvaluatingJavaScriptFromString(Native Method)\n[TRACE] I/dalvikvm( 1433): at android.webkit.BrowserFrame.stringByEvaluatingJavaScriptFromString(Native Method)\n[TRACE] I/dalvikvm( 1433): at android.webkit.BrowserFrame.loadUrl(BrowserFrame.java:138)\n[TRACE] I/dalvikvm( 1433): at android.webkit.WebViewCore.loadUrl(WebViewCore.java:1174)\n[TRACE] I/dalvikvm( 1433): at android.webkit.WebViewCore.access$900(WebViewCore.java:42)\n[TRACE] I/dalvikvm( 1433): at android.webkit.WebViewCore$EventHub$1.handleMessage(WebViewCore.java:663)\n[TRACE] I/dalvikvm( 1433): at android.os.Handler.dispatchMessage(Handler.java:99)\n[TRACE] I/dalvikvm( 1433): at android.os.Looper.loop(Looper.java:123)\n[TRACE] I/dalvikvm( 1433): at android.webkit.WebViewCore$WebCoreThread.run(WebViewCore.java:462)\n[TRACE] I/dalvikvm( 1433): at java.lang.Thread.run(Thread.java:1058)\n[TRACE] I/dalvikvm( 1433):\n[TRACE] E/dalvikvm( 1433): VM aborting\n[TRACE] I/DEBUG ( 555): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***\n[TRACE] I/DEBUG ( 555): Build fingerprint: 'generic/sdk/generic/:1.5/CUPCAKE/150240:eng/test-keys'\n[TRACE] I/DEBUG ( 555): pid: 1433, tid: 1444 >>> com.SelfService <<<\n[TRACE] I/DEBUG ( 555): signal 11 (SIGSEGV), fault addr deadd00d\n[TRACE] I/DEBUG ( 555): r0 00000328 r1 80000000 r2 0000000c r3 00000026\n[TRACE] I/DEBUG ( 555): r4 deadd00d r5 43678ea8 r6 ad083e10 r7 fffe6588\n[TRACE] I/DEBUG ( 555): r8 44dc7da0 r9 41047e18 10 41047e04 fp 00000001\n[TRACE] I/DEBUG ( 555): ip ad083eec sp 44dc6018 lr afe13e4d pc ad03b5c2 cpsr 20000030\n[TRACE] I/DEBUG ( 555): [#00](/projects/32238/tickets/00 \"Ticket #00\") pc 0003b5c2 /system/lib/libdvm.so\n......\n[TRACE] I/DEBUG ( 555): [#29](/projects/32238/tickets/29 \"Ticket #29\") pc 0000f3f4 /system/lib/libc.so\n[TRACE] I/DEBUG ( 555): stack:\n[TRACE] I/DEBUG ( 555): 44dc5fd8 00000005\n[TRACE] I/DEBUG ( 555): 44dc5fdc 00000000\n[TRACE] I/DEBUG ( 555): 44dc5fe0 afe39f90\n[TRACE] I/DEBUG ( 555): 44dc5fe4 afe39fe4\n[TRACE] I/DEBUG ( 555): 44dc5fe8 00000000\n[TRACE] I/DEBUG ( 555): 44dc5fec afe13e4d /system/lib/libc.so\n[TRACE] I/DEBUG ( 555): 44dc5ff0 001abbf8 [heap]\n[TRACE] I/DEBUG ( 555): 44dc5ff4 afe12e69 /system/lib/libc.so\n[TRACE] I/DEBUG ( 555): 44dc5ff8 fffe6588\n[TRACE] I/DEBUG ( 555): 44dc5ffc ad083e10\n[TRACE] I/DEBUG ( 555): 44dc6000 43678ea8\n[TRACE] I/DEBUG ( 555): 44dc6004 ad083e10\n[TRACE] I/DEBUG ( 555): 44dc6008 fffe6588\n[TRACE] I/DEBUG ( 555): 44dc600c afe12ecd /system/lib/libc.so\n[TRACE] I/DEBUG ( 555): 44dc6010 df002777\n[TRACE] I/DEBUG ( 555): 44dc6014 e3a070ad\n[TRACE] I/DEBUG ( 555): [#00](/projects/32238/tickets/00 \"Ticket #00\") 44dc6018 00000001\n[TRACE] I/DEBUG ( 555): 44dc601c ad02deb3 /system/lib/libdvm.so\n[TRACE] I/DEBUG ( 555): [#01](/projects/32238/tickets/01 \"Ticket #01\") 44dc6020 ad083e10\n[TRACE] I/DEBUG ( 555): 44dc6024 ad02e2b9 /system/lib/libdvm.so\n[TRACE] I/ActivityManager( 583): Process com.SelfService (pid 1433) has died.\n[TRACE] I/WindowManager( 583): WIN DEATH: Window{436dd0a0 com.SelfService/com.SelfService.SelfserviceActivity paused=false}\n[TRACE] W/InputManagerService( 583): Got RemoteException sending setActive(false) notification to pid 1433 uid 10019\n[TRACE] D/Zygote ( 557): Process 1433 terminated by signal (11)\n
{html}", "attachment": [], "flagged": false, "summary": "Android: Composite View addView Not Forcing UI Thread", "creator": { "name": "dthorp", "key": "dthorp", "displayName": "Don Thorp", "active": true, "timeZone": "America/Los_Angeles" }, "subtasks": [], "reporter": { "name": "dthorp", "key": "dthorp", "displayName": "Don Thorp", "active": true, "timeZone": "America/Los_Angeles" }, "environment": null, "comment": { "comments": [ { "id": "123045", "author": { "name": "dthorp", "key": "dthorp", "displayName": "Don Thorp", "active": true, "timeZone": "America/Los_Angeles" }, "body": "{html}

(from [58f4533ebecefc012ce636453ed2d6ab36d3102f])\n[#274\nstate:resolved] moved addView to the UI thread. The example in the\nticket won't work because it's trying to add view[0] into another\nview, which is not allowed after it's been viewed. \nhttp://github.com/appcelerator/titanium_mobile/commit/58f4533ebecef...

{html}", "updateAuthor": { "name": "dthorp", "key": "dthorp", "displayName": "Don Thorp", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2011-04-15T02:26:31.000+0000", "updated": "2011-04-15T02:26:31.000+0000" } ], "maxResults": 1, "total": 1, "startAt": 0 } } }