Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-24196] iOS: Debugging app with Safari throws error when adding event-listeners

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2016-12-05T19:05:52.000+0000
Affected Version/sRelease 6.0.0
Fix Version/sRelease 6.1.0
ComponentsiOS
Labelsdebugger, ios, jscore, safari
ReporterHans Knöchel
AssigneeChristopher Williams
Created2016-12-05T18:34:16.000+0000
Updated2016-12-05T23:02:43.000+0000

Description

In TIMOB-23871, we introduced the ability to debug apps with Safari - this is great! While testing around it, I found out that adding event listeners throws an error in the Inspector (no visible error on the app). The errors are caused by [this](https://github.com/appcelerator/titanium_mobile/blob/master/iphone/Classes/KrollObject.m#L1343) and [this](https://github.com/appcelerator/titanium_mobile/blob/master/iphone/Classes/KrollObject.m#L1359) line. They can be resolved by checking the value of jsEventHash beforehand (thanks [~cwilliams]!).

Attachments

FileDateSize
debugger-safari.m4v2016-12-05T19:05:09.000+00006108271

Comments

  1. Christopher Williams 2016-12-05

    https://github.com/appcelerator/titanium_mobile/pull/8659
  2. Hans Knöchel 2016-12-05

    *To test this ticket*: 1. Create a new app with appc new -p ios 1a. Ensure you have the <use-jscore-framework>true</use-jscore-framework> property in your <ios> section of the tiapp.xml 2. Paste the following code in your app:
       var win = Ti.UI.createWindow({
           backgroundColor: '#fff'
       });
       
       var btn1 = Ti.UI.createButton({
           title: 'Toggle event-listener #1',
           top: 40
       });
       
       btn1.addEventListener('click', function() {
           alert('#1 works!');
       });
       
       var btn2 = Ti.UI.createButton({
           title: 'Toggle event-listener #2',
           top: 120
       });
       
       btn2.addEventListener('click', myHandler);
       
       win.add(btn1);
       win.add(btn2);
       win.open();
       
       function myHandler() {
           alert('#2 works!');
       }
       
    3. Run the app in the iOS Simulator 4. Open Safari and select the app by navigating to Develop > Simulator > JSContext. If the menu is not there, enable it in Settings > Advanced > "Enable Develop menu in menu bar". 5. Set a breakpoint to both event listeners 6. Click both event listeners *Expected behavior*: The breakpoints are hit, the app doesn't crash and the Safari console does not throw any error. Please also see the attached video debugger-safari.m4v to see how I tested the PR.
  3. Samir Mohammed 2016-12-05

    Verified fixed, the Debugger on Safari no longer shows an error on event listeners and breakpoints are able to be hit (tested with the code provided above). *Environement*
       Appcelerator Command-Line Interface, version 6.0.0
       IOS 10.1
       IOS Simulator: iphone 7 plus 
       Safari version: 10.0.1 (11602.2.14.0.7)
       Operating System Name: Mac OS X El Capitan
       Operating System Version: 10.11.6
       Node.js Version: 4.6.0
       npm: 4.2.8
       Titanium CLI Version: 5.0.10
       Titanium SDK Version: 6.1.0.v20161204170304
       Xcode: 8.0
       Appcelerator Studio: 4.8.0.201611121409
       
  4. Samir Mohammed 2016-12-05

    Just realized didn't update the SDK Version build in the environement. ^
       Titanium SDK Version: 6.1.0.v20161205110006
       

JSON Source