Titanium JIRA Archive
Appcelerator Community (AC)

[AC-5771] Hyperloop iOS - NSThread callStackSymbols not returning array and data not usable

GitHub Issuen/a
TypeBug
Priorityn/a
StatusResolved
ResolutionInvalid
Resolution Date2018-06-18T11:15:32.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsHyperloop
Labelsalloy, hyperloop
ReporterDavid van de Meer
AssigneeShak Hossain
Created2018-06-18T03:17:46.000+0000
Updated2018-06-18T11:15:33.000+0000

Description

When using Hyperloop I am trying to get the NSThread callStackSymbols It is supposed to return an NSArray, but I am getting an object with key as $native. I have tried casting, create a new NSArray from the data etc but I am completely unable to use the data. Steps to reproduce: 1. Create new alloy hyperloop enabled project 2. In alloy.js, put this:
var NSThread = require('Foundation/NSThread');
var crashStackTrace = NSThread.callStackSymbols;
Ti.API.log(Object.prototype.toString.call(crashStackTrace));
Ti.API.log(Object.keys(crashStackTrace));
Ti.API.log(Object.values(crashStackTrace));
This logs out as:

[INFO]  [object Object]
[INFO]  (
[INFO]      "$native"
[INFO]  )
[INFO]  (
[INFO]          {
[INFO]          "__wrapper__" = "(\n\t0   CoreFoundation                      0x000000010af60ccc __invoking___ + 140\n\t1   CoreFoundation                      0x000000010af60b84 -[NSInvocation invoke] + 308\n\t2   alloy-hyperloop                     0x000000010a2a142e +[HyperloopUtils invokeSelector:args:target:instance:] + 1550\n\t3   alloy-hyperloop                     0x000000010a296081 Dispatch + 1489\n\t4   JavaScriptCore                      0x000000010f449b63 _ZN3JSC19APICallbackFunction4callINS_18JSCallbackFunctionEEExPNS_9ExecStateE + 595\n\t5   ???                                 0x00000430d4197034 0x0 + 4607763378228\n\t6   JavaScriptCore                      0x000000010f410d00 llint_entry + 29438\n\t7   JavaScriptCore                      0x000000010f40981a vmEntryToJavaScript + 304\n\t8   JavaScriptCore                      0x000000010f8ead43 _ZN3JSC7JITCode7executeEPNS_2VMEPNS_14ProtoCallFrameE + 147\n\t9   JavaScriptCore                      0x000000010f8a777b _ZN3JSC11Interpreter11executeCallEPNS_9ExecStateEPNS_8JSObjectENS_8CallTypeERKNS_8CallDataENS_7JSValueERKNS_7ArgListE + 523\n\t10  JavaScriptCore                      0x000000010faaf59e _ZN3JSC4callEPNS_9ExecStateENS_7JSValueENS_8CallTypeERKNS_8CallDataES2_RKNS_7ArgListE + 62\n\t11  JavaScriptCore                      0x000000010fb12e55 _ZN3JSC10callGetterEPNS_9ExecStateENS_7JSValueES2_ + 149\n\t12  JavaScriptCore                      0x000000010f973d9f llint_slow_path_get_by_id + 6223\n\t13  JavaScriptCore                      0x000000010f40cb5f llint_entry + 12637\n\t14  JavaScriptCore                      0x000000010f410d00 llint_entry + 29438\n\t15  JavaScriptCore                      0x000000010f40981a vmEntryToJavaScript + 304\n\t16  JavaScriptCore                      0x000000010f8ead43 _ZN3JSC7JITCode7executeEPNS_2VMEPNS_14ProtoCallFrameE + 147\n\t17  JavaScriptCore                      0x000000010f8a777b _ZN3JSC11Interpreter11executeCallEPNS_9ExecStateEPNS_8JSObjectENS_8CallTypeERKNS_8CallDataENS_7JSValueERKNS_7ArgListE + 523\n\t18  JavaScriptCore                      0x000000010faaf6d1 _ZN3JSC12profiledCallEPNS_9ExecStateENS_15ProfilingReasonENS_7JSValueENS_8CallTypeERKNS_8CallDataES3_RKNS_7ArgListE + 177\n\t19  JavaScriptCore                      0x000000010f458040 JSObjectCallAsFunction + 496\n\t20  alloy-hyperloop                     0x000000010a21c3c6 __TiBindingEventProcess_block_invoke + 86\n\t21  alloy-hyperloop                     0x000000010a0d140d TiThreadPerformOnMainThread + 77\n\t22  alloy-hyperloop                     0x000000010a21c26e TiBindingEventProcess + 1054\n\t23  alloy-hyperloop                     0x000000010a21c558 -[TiBindingCallbackInvoke invoke:] + 56\n\t24  alloy-hyperloop                     0x0000000109fcccaf -[KrollContext invoke:] + 159\n\t25  alloy-hyperloop                     0x0000000109fccd8a __24-[KrollContext enqueue:]_block_invoke + 42\n\t26  alloy-hyperloop                     0x000000010a0d140d TiThreadPerformOnMainThread + 77\n\t27  alloy-hyperloop                     0x0000000109fccd57 -[KrollContext enqueue:] + 135\n\t28  alloy-hyperloop                     0x000000010a21c5bf TiBindingRunLoopEnqueue + 95\n\t29  alloy-hyperloop                     0x000000010a21ba8e TiBindingEventFire + 334\n\t30  alloy-hyperloop                     0x000000010a092f30 -[TiProxy fireEvent:withObject:propagate:reportSuccess:errorCode:message:] + 208\n\t31  alloy-hyperloop                     0x0000000109ff4872 -[TiViewProxy fireEvent:withObject:propagate:reportSuccess:errorCode:message:] + 418\n\t32  alloy-hyperloop                     0x000000010a0857f3 -[TiUIButtonProxy fireEvent:withObject:propagate:reportSuccess:errorCode:message:] + 259\n\t33  alloy-hyperloop                     0x000000010a092b5b -[TiProxy fireEvent:withObject:] + 139\n\t34  alloy-hyperloop                     0x000000010a087be1 -[TiUIButton controlAction:forEvent:] + 705\n\t35  UIKit                               0x000000010c33e3e8 -[UIApplication sendAction:to:from:forEvent:] + 83\n\t36  UIKit                               0x000000010c4b97a4 -[UIControl sendAction:to:forEvent:] + 67\n\t37  UIKit                               0x000000010c4b9ac1 -[UIControl _sendActionsForEvents:withEvent:] + 450\n\t38  UIKit                               0x000000010c4b8a09 -[UIControl touchesEnded:withEvent:] + 580\n\t39  UIKit                               0x000000010c3b30bf -[UIWindow _sendTouchesForEvent:] + 2729\n\t40  UIKit                               0x000000010c3b47c1 -[UIWindow sendEvent:] + 4086\n\t41  UIKit                               0x000000010c358310 -[UIApplication sendEvent:] + 352\n\t42  UIKit                               0x000000010cc996af __dispatchPreprocessedEventFromEventQueue + 2796\n\t43  UIKit                               0x000000010cc9c2c4 __handleEventQueueInternal + 5949\n\t44  CoreFoundation                      0x000000010af7fbb1 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17\n\t45  CoreFoundation                      0x000000010af644af __CFRunLoopDoSources0 + 271\n\t46  CoreFoundation                      0x000000010af63a6f __CFRunLoopRun + 1263\n\t47  CoreFoundation                      0x000000010af6330b CFRunLoopRunSpecific + 635\n\t48  GraphicsServices                    0x0000000114fdba73 GSEventRunModal + 62\n\t49  UIKit                               0x000000010c33d057 UIApplicationMain + 159\n\t50  alloy-hyperloop                     0x0000000109fb2794 main + 100\n\t51  libdyld.dylib                       0x00000001143ce955 start + 1\n\t52  ???                                 0x0000000000000001 0x0 + 1\n)";
[INFO]      }
[INFO]  )

Comments

  1. Hans Knöchel 2018-06-18

    It returns an NSArray instance that needs to be accessed via objectAtIndex. Working example:
       var NSThread = require('Foundation/NSThread');
       var win = Ti.UI.createWindow({ backgroundColor: '#fff' });
       
       var btn = Ti.UI.createButton({
           title: 'Test'
       });
       
       btn.addEventListener('click', function () {
           try {
               btn.crash();
           } catch (e) {
               var crashStackTrace = NSThread.callStackSymbols;
       
               for (var i = 0; i < crashStackTrace.count; i++) {
                   Ti.API.warn(crashStackTrace.objectAtIndex(i));    
               }
           }
       });
       
       win.add(btn);
       win.open();
       

JSON Source