[TIMOB-4074] iOS: KitchenSink reports script error when running Platform>Passing Data (windows)
GitHub Issue | n/a |
Type | Bug |
Priority | Medium |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2011-05-24T14:35:12.000+0000 |
Affected Version/s | Release 1.7.0 |
Fix Version/s | Backlog |
Components | iOS |
Labels | KitchenSink |
Reporter | Eric Merriman |
Assignee | Blain Hamon |
Created | 2011-05-13T11:05:58.000+0000 |
Updated | 2011-05-24T14:35:12.000+0000 |
Description
Description:
While running KS, Platform>Passing Data (windows), the view came up empty and the console reported errors:
Fri May 13 09:59:44 unknown UIKitApplication:com.appcelerator.pushtest[0x93b2][5058] : [ERROR] Script Error = Result of expression 'win.myFunc' [undefined] is not a function. at custom_properties_2.js (line 1).
Fri May 13 09:59:44 unknown UIKitApplication:com.appcelerator.pushtest[0x93b2][5058] : [ERROR] application received error: Result of expression 'win.myFunc' [undefined] is not a function. at custom_properties_2.js (line 1)
Steps to reproduce:
1) Install KS
2) navigate to Platform>Passing Data (windows)
3) Click "launch window"
Result:
Empty page and console errors
Expected result:
Notes:
Does not occur on 1.6.2
Attachments
Tested iPad (Universal KS)/4.3.3.
Have to let Blain log his hours!
Forgot to log the hours before it got closed. Whoops.
Blain logged work, can close now for reals.
Issue found by the community: https://github.com/appcelerator/titanium_mobile/commit/7bef2bd0bcb7abbded1b9cccbbd187ee056788d7#commitcomment-390894
Turns out that contexts sharing functions leads to all sorts of crazy threading issues, and may have been a cause of crashers in the past. As a workaround, eventListeners ARE threadsafe, and while Ti.App event listeners have an issue with native items (TIMOB-4155) event listeners on native items work. For example, the workaround for the example provided would be thusly: {{ App.js: var win = Ti.UI.createWindow(); var b = Ti.UI.createButton({ title:'Open', width:140, height:40 }); win.add(b); b.addEventListener('click', function() { var w = Ti.UI.createWindow({ url:'opening.js' }); w.addEventListener('rotateLeft',function (e){ var the_view = e.view; var angle = e.angle; var duration=e.duration; if(the_view==null || the_view==undefined){ return; } var t = Ti.UI.create2DMatrix(); t = t.rotate(angle); var a = Titanium.UI.createAnimation(); a.transform = t; a.duration = duration; the_view.animate(a); }); w.open(); }); win.open(); opening.js: var win = Ti.UI.currentWindow; var v = Ti.UI.createView({backgroundColor:'red', width:100, height:100}); win.add(v); win.fireEvent('rotateLeft',{view:v,angle:45,duration:0.2}); }}
To be bug-compatible, when a proxy is being made in the wrong context, we register in the current context just to ensure it's still out and about.
Verified fixed with iPad 3.2.3 and iPad 4.3, Titanium Studio, build: 1.0.0.201105131803, Titanium SDK version: 1.7.X r3982f4e7.