Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-10501] iOS: No error logging on non-exported CommonJS code

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2012-09-13T14:31:22.000+0000
Affected Version/sRelease 2.1.1, Release 3.0.0
Fix Version/sRelease 2.1.3, Release 3.0.0, Sprint 2012-19 Core, 2012 Sprint 19
ComponentsiOS
LabelsSupportTeam, core, module_api, qe-testadded
ReporterEduardo Gomez
AssigneeMax Stepanov
Created2012-08-20T14:50:25.000+0000
Updated2013-10-07T11:56:29.000+0000

Description

Problem

Error console does not log errors that occur within CommonJS modules outside of the Exported code.

Expected results

module.js should error on line 13 as foobar() is not a valid method of UI.view.

Actual result

No error is raised until line 10 of app.js, when the empty object is added to the window.

Tested on

iOS simulator

app.js

Titanium.UI.setBackgroundColor('#000');

var win = Titanium.UI.createWindow({  
  	title: 'test'
});

var obj = require('module');
win.add(obj);

win.open();

module.js

exports = function(){
	return createObj();
}

function createObj(){
	var view = Ti.UI.createView({
		width: 20,
		height: 20,
		backgroundColor:'red'
	});
	
	//force error
	view.foobar();
	
	return view;
}

Console output

[INFO] One moment, building ...
[INFO] Detected third-party module: ti.location/1.0
[INFO] Detected third-party module: ti.location/1.0
[INFO] Titanium SDK version: 2.2.0 (08/01/12 17:01 b2782e9)
[INFO] iPhone Device family: universal
[INFO] iPhone SDK version: 5.1
[INFO] iPhone simulated device: iphone
[INFO] Performing full rebuild. This will take a little bit. Hold tight...
[WARN] The project seems to be having custom info.plist which does not contain  the CFBundleShortVersionString key
[INFO] Generating the missing CFBundleShortVersionString key
[INFO] Minimum iOS version: 4.0
[INFO] Performing clean build
[INFO] Launching application in Simulator
[INFO] Launched application in Simulator (31.34 seconds)
[INFO] Application started
[INFO] 1BestPractices/1.0 (2.2.0.v20120801170113.b2782e9)
[ERROR] Script Error = -[KrollCallback krollObjectForBridge:]: unrecognized selector sent to instance 0x8e95ed0 at app.js (line 8).
[INFO] Application has exited from Simulator

Customer's output

[INFO] One moment, building ...
[DEBUG] Detecting modules in /Users/allenhartwig/Documents/Titanium Studio Workspace/test/modules
[DEBUG] Detecting modules in /Users/allenhartwig/Library/Application Support/Titanium/modules
[DEBUG] Detected module for android: ti.cloudpush 2.0.5 @ /Users/allenhartwig/Library/Application Support/Titanium/modules/android/ti.cloudpush/2.0.5
[DEBUG] Detected module for android: ti.cloudpush 2.0.1 @ /Users/allenhartwig/Library/Application Support/Titanium/modules/android/ti.cloudpush/2.0.1
[DEBUG] Detected module for commonjs: ti.cloud 2.2.0 @ /Users/allenhartwig/Library/Application Support/Titanium/modules/commonjs/ti.cloud/2.2.0
[DEBUG] Detected module for commonjs: ti.cloud 2.1.0 @ /Users/allenhartwig/Library/Application Support/Titanium/modules/commonjs/ti.cloud/2.1.0
[DEBUG] Detected module for commonjs: ti.cloud 2.0.5 @ /Users/allenhartwig/Library/Application Support/Titanium/modules/commonjs/ti.cloud/2.0.5
[DEBUG] Detected module for commonjs: ti.cloud 2.0.1 @ /Users/allenhartwig/Library/Application Support/Titanium/modules/commonjs/ti.cloud/2.0.1
[DEBUG] Detected module for iphone: ti.worker 1.0 @ /Users/allenhartwig/Library/Application Support/Titanium/modules/iphone/ti.worker/1.0
[DEBUG] Detected module for iphone: ti.viewshadow 0.2 @ /Users/allenhartwig/Library/Application Support/Titanium/modules/iphone/ti.viewshadow/0.2
[INFO] Titanium SDK version: 2.2.0 (08/08/12 13:21 5205295)
[INFO] iPhone Device family: iphone
[INFO] iPhone SDK version: 5.1
[INFO] iPhone simulated device: iphone
[DEBUG] linking: /Users/allenhartwig/Documents/Titanium Studio Workspace/test/Resources/app.js to /Users/allenhartwig/Documents/Titanium Studio Workspace/test/build/iphone/build/Debug-iphonesimulator/test.app/app.js
[DEBUG] creating: /Users/allenhartwig/Documents/Titanium Studio Workspace/test/build/iphone/build/Debug-iphonesimulator/test.app/iphone
[DEBUG] linking: /Users/allenhartwig/Documents/Titanium Studio Workspace/test/Resources/iphone/appicon.png to /Users/allenhartwig/Documents/Titanium Studio Workspace/test/build/iphone/build/Debug-iphonesimulator/test.app/iphone/appicon.png
[DEBUG] linking: /Users/allenhartwig/Documents/Titanium Studio Workspace/test/Resources/iphone/Default-Landscape.png to /Users/allenhartwig/Documents/Titanium Studio Workspace/test/build/iphone/build/Debug-iphonesimulator/test.app/iphone/Default-Landscape.png
[DEBUG] linking: /Users/allenhartwig/Documents/Titanium Studio Workspace/test/Resources/iphone/Default-Portrait.png to /Users/allenhartwig/Documents/Titanium Studio Workspace/test/build/iphone/build/Debug-iphonesimulator/test.app/iphone/Default-Portrait.png
[DEBUG] linking: /Users/allenhartwig/Documents/Titanium Studio Workspace/test/Resources/iphone/Default.png to /Users/allenhartwig/Documents/Titanium Studio Workspace/test/build/iphone/build/Debug-iphonesimulator/test.app/iphone/Default.png
[DEBUG] linking: /Users/allenhartwig/Documents/Titanium Studio Workspace/test/Resources/iphone/Default@2x.png to /Users/allenhartwig/Documents/Titanium Studio Workspace/test/build/iphone/build/Debug-iphonesimulator/test.app/iphone/Default@2x.png
[DEBUG] linking: /Users/allenhartwig/Documents/Titanium Studio Workspace/test/Resources/KS_nav_ui.png to /Users/allenhartwig/Documents/Titanium Studio Workspace/test/build/iphone/build/Debug-iphonesimulator/test.app/KS_nav_ui.png
[DEBUG] linking: /Users/allenhartwig/Documents/Titanium Studio Workspace/test/Resources/KS_nav_views.png to /Users/allenhartwig/Documents/Titanium Studio Workspace/test/build/iphone/build/Debug-iphonesimulator/test.app/KS_nav_views.png
[DEBUG] linking: /Users/allenhartwig/Documents/Titanium Studio Workspace/test/Resources/module.js to /Users/allenhartwig/Documents/Titanium Studio Workspace/test/build/iphone/build/Debug-iphonesimulator/test.app/module.js
[DEBUG] linking: /Users/allenhartwig/Documents/Titanium Studio Workspace/test/Resources/iphone/appicon.png to /Users/allenhartwig/Documents/Titanium Studio Workspace/test/build/iphone/build/Debug-iphonesimulator/test.app/appicon.png
[DEBUG] linking: /Users/allenhartwig/Documents/Titanium Studio Workspace/test/Resources/iphone/Default-Landscape.png to /Users/allenhartwig/Documents/Titanium Studio Workspace/test/build/iphone/build/Debug-iphonesimulator/test.app/Default-Landscape.png
[DEBUG] linking: /Users/allenhartwig/Documents/Titanium Studio Workspace/test/Resources/iphone/Default-Portrait.png to /Users/allenhartwig/Documents/Titanium Studio Workspace/test/build/iphone/build/Debug-iphonesimulator/test.app/Default-Portrait.png
[DEBUG] linking: /Users/allenhartwig/Documents/Titanium Studio Workspace/test/Resources/iphone/Default.png to /Users/allenhartwig/Documents/Titanium Studio Workspace/test/build/iphone/build/Debug-iphonesimulator/test.app/Default.png
[DEBUG] linking: /Users/allenhartwig/Documents/Titanium Studio Workspace/test/Resources/iphone/Default@2x.png to /Users/allenhartwig/Documents/Titanium Studio Workspace/test/build/iphone/build/Debug-iphonesimulator/test.app/Default@2x.png
[INFO] Minimum iOS version: 4.0
[DEBUG] executing command: /usr/bin/killall ios-sim
[DEBUG] No matching processes belonging to you were found
[DEBUG] executing command: /usr/bin/killall iPhone Simulator
[DEBUG] No matching processes belonging to you were found
[DEBUG] finding old log files
[DEBUG] executing command: mdutil -a -s
[DEBUG] /:
[DEBUG] Indexing enabled.
[DEBUG] /Volumes/Downloads:
[DEBUG] Server search enabled.
[DEBUG] /Volumes/HPVirtualRooms:
[DEBUG] Indexing disabled.
[DEBUG] Searching for old log files with mdfind...
[DEBUG] executing command: mdfind -onlyin /Users/allenhartwig/Library/Application Support/iPhone Simulator/5.1 -name 430cbd11-d4d2-4e12-92a6-4ed2196751d0.log
[INFO] Launching application in Simulator
[INFO] Launched application in Simulator (18.53 seconds)
[INFO] Application started
[DEBUG] Reading stylesheet from: /Users/allenhartwig/Library/Application Support/iPhone Simulator/5.1/Applications/026293D3-C940-4551-932F-794BA0CAC799/test.app/stylesheet.plist
[INFO] test/1.0 (2.2.0.v20120808132114.5205295)
[DEBUG] Analytics is enabled = YES
[DEBUG] Loading: /Users/allenhartwig/Library/Application Support/iPhone Simulator/5.1/Applications/026293D3-C940-4551-932F-794BA0CAC799/test.app/app.js, Resource: app_js
[DEBUG] Loading: /Users/allenhartwig/Library/Application Support/iPhone Simulator/5.1/Applications/026293D3-C940-4551-932F-794BA0CAC799/test.app/module.js, Resource: module_js
2012-08-19 14:22:17.755 test[33786:1ac03] -[KrollCallback krollObjectForBridge:]: unrecognized selector sent to instance 0x9948060
[ERROR] Script Error = -[KrollCallback krollObjectForBridge:]: unrecognized selector sent to instance 0x9948060 at app.js (line 10).
[DEBUG] Application booted in 198.106050 ms
Terminating in response to SpringBoard's termination.
[INFO] Application started
[DEBUG] Reading stylesheet from: /Users/allenhartwig/Library/Application Support/iPhone Simulator/5.1/Applications/026293D3-C940-4551-932F-794BA0CAC799/test.app/stylesheet.plist
[INFO] test/1.0 (2.2.0.v20120808132114.5205295)
[DEBUG] Analytics is enabled = YES
[DEBUG] Loading: /Users/allenhartwig/Library/Application Support/iPhone Simulator/5.1/Applications/026293D3-C940-4551-932F-794BA0CAC799/test.app/app.js, Resource: app_js
[DEBUG] Loading: /Users/allenhartwig/Library/Application Support/iPhone Simulator/5.1/Applications/026293D3-C940-4551-932F-794BA0CAC799/test.app/module.js, Resource: module_js
2012-08-19 14:22:48.378 test[33837:1ac03] -[KrollCallback krollObjectForBridge:]: unrecognized selector sent to instance 0x9919ae0
[ERROR] Script Error = -[KrollCallback krollObjectForBridge:]: unrecognized selector sent to instance 0x9919ae0 at app.js (line 10).
[DEBUG] Application booted in 10.446966 ms

Comments

  1. Eduardo Gomez 2012-08-20

    @Neeraj - From that standpoint I'd agree. If the mechanism that forces the error is removed, the app would successfully compile as per the following settings: - app.js
       Titanium.UI.setBackgroundColor('#000');
        
       var win = Titanium.UI.createWindow({  
           title: 'test'
       });
        
       var obj = require('module')();
       win.add(obj);
        
       win.open();
       
    - module.js
       exports = function(){
           return createObj();
       };
        
       function createObj(){
           var view = Ti.UI.createView({
               width: 20,
               height: 20,
               backgroundColor:'red'
           });
            
           //force error
           //view.foobar();
            
           return view;
       }
       
    However when the presence of the mechanism described before is in module.js (by just uncommenting view.foobar(); method of UIView) the app would throw the following error: - [ERROR] Script Error = 'undefined' is not a function (evaluating 'view.foobar()') (unknown file). Which is not useful when debugging larger and complex apps (whether on exported or non exported commonJS modules), and basically what this jira ticket address.
  2. Max Stepanov 2012-09-11

    PR pending https://github.com/appcelerator/titanium_mobile/pull/2906 Fixes source file information for error reporting. Please note that line information displayed is expected to be incorrect given that JS code is compressed within modules.
  3. Blain Hamon 2012-09-13

    Pull merged
  4. Max Stepanov 2012-09-14

    Backport PR https://github.com/appcelerator/titanium_mobile/pull/2964
  5. Lokesh Choudhary 2012-09-21

    Verified fix on: Titanium studio : 2.1.2.201208301612 SDK version : 2.1.3.v20120920154617 SDK Version : 3.0.0.v20120921051359 iOS simulator xcode 4.5

JSON Source