Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-9502] iOS: Focus and open events don't fire on first window when require() is used

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2013-09-17T21:26:54.000+0000
Affected Version/sRelease 2.1.0
Fix Version/sRelease 2.1.0, Sprint 2012-12 API, 2013 Sprint 19, 2013 Sprint 19 API, Release 3.1.3, Release 3.2.0
ComponentsiOS
Labelsapi, module_window, qe-testadded, regression, titanbeta, triage
ReporterShawn Lipscomb
AssigneeVishal Duggal
Created2012-06-12T12:47:48.000+0000
Updated2013-12-02T09:14:53.000+0000

Description

Problem

There is a regression in mobile SDK 2.1.0.v20120608174150 that causes an intermittent failure of open and focus events at the Window level. Sometimes neither event will fire. Sometimes the open event fires but the focus event won't.

Testcase

Use the sample project that is attached. This code is reduced down from a much larger app. I have reduced it down as far as I can and still demonstrate the problem. You'll notice that much of the code in the require()d and/or include()d units is not executed, but removing it hides the problem. During testing, I noticed that volume of code seemed to affect the reproducibility of the problem. Just run the app, and look at the console log. You may need to run it several times! In my testing, it failed more often than it succeeded.

Expected Result

In the console log you should see: {panel} == Loading Procs == Loading Themes top bottom MainWinLoad fired MainWinFocus fired from [object Object] {panel}

Actual Result

{panel} == Loading Procs == Loading Themes top bottom {panel} sometimes the "MainWinLoad fired" line will show up, and sometimes the "MainWinFocus fired from [object Object]" line also appears.

Attachments

FileDateSize
FocusOpenMemoryTest.zip2012-06-12T12:47:48.000+0000128897

Comments

  1. Vishal Duggal 2012-06-13

    Pull pending https://github.com/appcelerator/titanium_mobile/pull/2385
  2. Shawn Lipscomb 2012-06-15

    HD ticket: [APP-152528](https://support.appcelerator.com/tickets/APP-152528)
  3. Shawn Lipscomb 2012-06-15

    Verified fixed in SDK 2.1.0.v20120615132253. Thanks!
  4. Michael Pettiford 2012-06-19

    Closing issue Tested with Ti Studio build 2.1.0.201206172244 Ti Mobile SDK 2.1.0.v20120618154152 hash r7830c03d OSX Lion 10.7.3 iPhone 4S OS 5.1 The expected behavior is shown
  5. Neha Chhabra 2012-07-12

    Reopening to update labels.
  6. Priya Agarwal 2013-09-17

    Tested Environment: Appcelerator Studio: 3.1.3.201309132456 SDK: 3.1.3.v20130916153052 acs:1.0.6 alloy:1.2.2-cr npm:1.3.2 titanium:3.1.2 titanium-code-processo:1.0.2 OSX: 10.8.4 Xcode:5.0 GM seed Device:ipad3(v7.0),iphone4s(v7.0)and ipodtouch3(v6.1.3) Expected Result on console logs are: == Loading Procs == Loading Themes top bottom MainWinLoad fired MainWinFocus fired from [object Object] Getting the expected console logs with 3.1.2.GA sdk build but with 3.1.3.v20130916153052 build not getting the expected result. Focus event is not being fired on first window when require() is used.
  7. Olga Romero 2013-09-17

    I do NOT see [INFO] : MainWinFocus fired from [object Object] The rest is as expected: [INFO] : == Loading Procs [INFO] : == Loading Themes [INFO] : top [INFO] : bottom [INFO] : MainWinLoad fired Tested with: Appcelerator Studio: 3.1.3.201309132456 Titanium SDK, build: 3.1.3.v20130916153052 Mac osx 10.8.4 Mountain Lion Xcode5 alloy@1.2.2-cr CLI version : 3.1.2 Devices: iPhone4(iOS7 GM seed) iPhone5 iOS7(11A465)
  8. Vishal Duggal 2013-09-17

    Test Code
       ########app.js#######
       Ti.UI.backgroundColor = 'white';
       
       var win = Ti.UI.createWindow({
           backgroundColor : "#fff",
           url:'testWin.js',
           title:'URL WINDOW',
           layout:'vertical'
       });
       
       
       var nav = Ti.UI.iOS.createNavigationWindow({
           window:win
       })
       
       win.addEventListener('open',function(){
           Ti.API.info('GOT OPEN EVENT IN MAIN CONTEXT')
       })
       
       win.addEventListener('focus',function(){
           Ti.API.info('GOT FOCUS EVENT IN MAIN CONTEXT')
       })
       
       
       var mainWin = Ti.UI.createWindow();
       
       var btn = Ti.UI.createButton({
           title:'OPEN'
       })
       
       btn.addEventListener('click',function(){
           nav.open();
       })
       
       mainWin.add(btn);
       
       mainWin.open();
       
       
       ########testWin.js########
       
       var curWin = Ti.UI.currentWindow;
       
       var l1 = Ti.UI.createLabel({
       	top:20,
       	text:'WAITING FOR OPEN EVENT'
       })
       
       var l2 = Ti.UI.createLabel({
       	top:10,
       	text:'WAITING FOR FOCUS EVENT'
       })
       
       curWin.add(l1);
       curWin.add(l2);
       
       
       curWin.addEventListener('open',function(){
       	l1.text = 'GOT OPEN EVENT IN URL CONTEXT';
       })
       
       curWin.addEventListener('focus',function(){
       	l2.text = 'GOT FOCUS EVENT IN URL CONTEXT';
       })
       
       
  9. Vishal Duggal 2013-09-17

    Pull pending master - https://github.com/appcelerator/titanium_mobile/pull/4705 3_1_X - https://github.com/appcelerator/titanium_mobile/pull/4706
  10. Priya Agarwal 2013-09-18

    Verified the fix on: Appcelerator Studio: 3.1.3.201309132456 
SDK: 3.1.3.v20130917141554
 acs:1.0.6 
alloy:1.2.2-cr
 npm:1.3.2 
titanium:3.1.2
 titanium-code-processo:1.0.3-cr
 OSX: 10.8.4 
Xcode:5.0 GM seed 
Device: ipod touch2(v7.0) Using both the code verified the focus and open event of window being fired. Hence closing the issue as fixed.

JSON Source