Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-27846] iOS: Calling Ti.Platform.openURL without all parameters causes the app to crash (regression)

GitHub Issuen/a
TypeBug
PriorityCritical
StatusClosed
ResolutionFixed
Resolution Date2020-07-20T14:12:30.000+0000
Affected Version/sRelease 9.0.1, Release 9.0.0, Release 9.0.2, Release 9.0.3
Fix Version/sRelease 9.1.0
ComponentsiOS
Labelsios, regression
ReporterHugo Ramos Freire Neto
AssigneeChristopher Williams
Created2020-03-10T17:37:42.000+0000
Updated2020-08-07T13:29:08.000+0000

Description

When I use Ti.Platform.openURL, and the app goes to background, the app crashes with this error: [ERROR] Script Error { [ERROR] toJSON = ""; [ERROR] }

Attachments

FileDateSize
index.js2020-03-10T17:34:18.000+0000181

Comments

  1. Satyam Sekhri 2020-04-13

    The issue is a regression in SDK 9.0.0.GA. Do not see this issue with SDK 8.3.1.GA. Tested with Mac OS: 10.15.4 SDK: 9.0.0.GA, 8.3.1.GA Appc CLI: 8.0.0 JDK: 11.0.4 Node: 10.17.0 Studio: 6.0.0.202003181504 Xcode: 11.4 Device: iOS simulator 13.4, iOS simulator 12.2
  2. Jonas Funk Johannessen 2020-06-12

    Seeing this as well. Adding the optional callback parameter will remove error: Ti.Platform.openURL(url, null, ()=>{});
  3. Michael Gangolf 2020-06-26

  4. Hans Knöchel 2020-07-19

    How can this issue not be scheduled so far? SDK 9 regression, critical crash, reproducible every time, already 3+ months old. Come on Axway!
  5. Hans Knöchel 2020-07-19

    PR: https://github.com/appcelerator/titanium_mobile/pull/11826 Example:
       function doInverval() {
           console.log('interval called');
       }
       
       function doClick(e) {
           Ti.Platform.openURL('https://google.com', {}, function() {});
       }
       
       var win = Ti.UI.createWindow({
           backgroundColor: '#fff'
       });
       
       var btn = Ti.UI.createButton({
           title: 'Open URL'
       });
       
       btn.addEventListener('click', doClick);
       
       let interval = setInterval(doInverval, 1000);
       
       win.add(btn);
       win.open();
       
  6. Christopher Williams 2020-07-20

    Well this was a dumb error on my part. I misunderstood how the new JSC API would handle an optional callback argument - I assumed it'd be nil. It is not! It's a JSValue \* equivalent to undefined. So any APIs with an optional callback using the new JSC API need to explicitly check the arg is both not nil, *and* is actually a function. Thanks for the PR [~hknoechel], that's what clued me in to the issue here. The fix is relatively straight-forward and I'll push it today.
  7. Christopher Williams 2020-07-20

    Fixed in https://github.com/appcelerator/titanium_mobile/commit/31424c6c2e85ad5d18c5d45c156221545e8a0e22 (cherry-picked to 9_1_X and 9_3_X)
  8. Christopher Williams 2020-07-20

    For good measure, I also cherry-picked back to 9_0_X branch
  9. Samir Mohammed 2020-07-27

    *Closing ticket*. Fix verified in SDK version 9.1.0.v20200724110711, 9.2.0.v20200724112452, 9.0.4.v20200720071447 and 9.3.0.v20200724114100. Tested using the following test case:
       var win = Ti.UI.createWindow({
       	title: 'Ti.Platform.openURL Bug'
       });
       win.open();
       
       var button = Ti.UI.createButton({
       	top: 100,
       	height: Ti.UI.SIZE,
       	title: 'Open maps'
       });
       button.addEventListener('click', function() {
       	Ti.Platform.openURL('http://maps.apple.com/maps?q=-8.012960,110.308998');
       });
       win.add(button);
       
       setInterval(function() {
       	Ti.Platform.openURL('http://maps.apple.com/maps?q=-8.012960,110.308998');
       }, 10000);
       
    Test and other information can be found at: https://github.com/appcelerator/titanium_mobile/commit/31424c6c2e85ad5d18c5d45c156221545e8a0e22 *Test Environment*
       MacOS Big Sur: 11.0 Beta
       Xcode: 12.0 Beta 
       Java Version: 1.8.0_242
       Android NDK: 21.3.6528147
       Node.js: 12.18.1
       ""NPM":"5.0.0","CLI":"8.1.0-master.5""
       iphone 8 Sim (14.0 Beta)
       

JSON Source