edusperoni / nativescript-mqtt

MQTT 3.1.1 for Nativescript
Apache License 2.0
12 stars 3 forks source link

Intermittent crash on call to subscribe #18

Closed kryptus36 closed 2 years ago

kryptus36 commented 3 years ago

Which platform(s) does your issue occur on?

Please, provide the following version numbers that your issue occurs with:

"dependencies": { "@nativescript-community/ui-pager": "^13.0.11", "@nativescript/appversion": "^2.0.0", "@nativescript/core": "~7.1.0", "@nativescript/firebase": "^11.0.0", "@nativescript/geolocation": "^7.0.0", "@nativescript/iqkeyboardmanager": "^2.0.0", "@nativescript/secure-storage": "^3.0.0", "@nativescript/theme": "^3.0.0", "@nstudio/nativescript-exoplayer": "^5.0.4", "@proplugins/nativescript-masked-text-field": "^6.0.0", "@proplugins/nativescript-orientation": "^2.5.0", "@types/node": "^12.12.7", "moment": "^2.27.0", "moment-timezone": "^0.5.28", "nativescript-audio-player": "^1.0.3", "nativescript-google-maps-sdk": "^3.0.2", "nativescript-insomnia": "^2.0.0", "nativescript-mqtt": "^3.0.1", "nativescript-ui-listview": "^9.0.2", "nativescript-ui-sidedrawer": "^9.0.3", "nativescript-webview-interface": "^1.4.4", "nativescript-websockets": "^1.5.6" }, "devDependencies": { "@nativescript/android": "7.0.1", "@nativescript/ios": "7.2.0", "@nativescript/types": "7.0.0", "@nativescript/webpack": "~4.0.0", "node-sass": "^4.14.1", "tslint": "^6.1.1", "typescript": "3.9.7" },

Please, tell us how to recreate the issue in as much detail as possible.

Describe the steps to reproduce it.

upon calling mqtt.subscribe I get:

====== Assertion failed ====== Native stack trace: 1 0x104cbc9ff tns::Assert(bool, v8::Isolate) + 119 2 0x104c3fc39 tns::ArgConverter::Invoke(v8::Local, objc_class, v8::Local, tns::V8Args&, tns::MethodMeta const, bool) + 95 3 0x104c976dc tns::MetadataBuilder::InvokeMethod(v8::Local, tns::MethodMeta const, v8::Local, tns::V8Args&, std::1::basic_string<char, std::__1::char_traits, std::1::allocator >, bool) + 76 4 0x104c96ff7 tns::MetadataBuilder::MethodCallback(v8::FunctionCallbackInfo const&) + 225 5 0x104dea0a1 v8::internal::FunctionCallbackArguments::Call(v8::internal::CallHandlerInfo) + 609 6 0x104de958a v8::internal::MaybeHandle v8::internal::(anonymous namespace)::HandleApiCallHelper(v8::internal::Isolate, v8::internal::Handle, v8::internal::Handle, v8::internal::Handle, v8::internal::Handle, v8::internal::BuiltinArguments) + 570 7 0x104de8bad v8::internal::Builtin_Impl_HandleApiCall(v8::internal::BuiltinArguments, v8::internal::Isolate) + 253 8 0x1056bf7b9 Builtins_CEntry_Return1_DontSaveFPRegs_ArgvOnStack_BuiltinExit + 57 9 0x10565e1f9 Builtins_InterpreterEntryTrampoline + 185 JavaScript stack trace: at createTimerAndGetId (file: node_modules/@nativescript/core/timer/index.ios.js:45:0) at setTimeout (file: node_modules/@nativescript/core/timer/index.ios.js:55:0) at Pinger.reset (file: node_modules/nativescript-mqtt/paho-mqtt.js:759:0) at LibraryFactory.ClientImpl._socket_send (file: node_modules/nativescript-mqtt/paho-mqtt.js:1501:0) at LibraryFactory.ClientImpl._process_queue (file: node_modules/nativescript-mqtt/paho-mqtt.js:1200:0) at LibraryFactory.ClientImpl._schedule_message (file: node_modules/nativescript-mqtt/paho-mqtt.js:1108:0) at LibraryFactory.ClientImpl.subscribe (file: node_modules/nativescript-mqtt/paho-mqtt.js:949:0) at Client.subscribe (file: node_modules/nativescript-mqtt/paho-mqtt.js:2103:0) at subscribe (file: node_modules/nativescript-mqtt/mqtt.js:116:0)

edusperoni commented 3 years ago

Can you use setTimeout normally? I've just ran the tests and updated the demo to the latest Nativescript version and all is passing.

kryptus36 commented 3 years ago

I'm having a near impossible time tracking this. I no longer get the above error though. I'm getting a silent crash, and upon implementing sentry.io it's trying to access a bad pointer. But it's really intermittent. I'm not even sure next steps. It does appear websocket related, not necessarily mqtt.

sentry

kryptus36 commented 3 years ago

Is it possible it's something environment related? I just tested the demo app straight from git and I get a silent crash, sometimes on hitting connect, but if the connection succeeds, it crashes upon trying to subscribe to a topic.

mcgouganp commented 3 years ago

I’m seeing, what I believe is, a similar problem. A silent crash when data is sent on the socket. Sometimes on connect, sometimes on subscribe, sometimes on a publish. But it all seems to track back to socket sending.

Looks like possibly a bug in the underlying PocketSocket native code. I get this crash information in Xcode when running the demo app:

5 0x0000000103efb3e4 in -[PSWebSocketBuffer appendData:] at /Users/paulmcgougan/Projects/nativescript-mqtt/demo/platforms/ios/Pods/PocketSocket/PocketSocket/PSWebSocketBuffer.m:47

6 0x0000000103ef9d74 in -[PSWebSocket driver:write:] at /Users/paulmcgougan/Projects/nativescript-mqtt/demo/platforms/ios/Pods/PocketSocket/PocketSocket/PSWebSocket.m:577

7 0x0000000103efe4c4 in -[PSWebSocketDriver writeMessageWithOpCode:data:] at /Users/paulmcgougan/Projects/nativescript-mqtt/demo/platforms/ios/Pods/PocketSocket/PocketSocket/PSWebSocketDriver.m:397

8 0x0000000103efca9c in -[PSWebSocketDriver sendBinary:] at /Users/paulmcgougan/Projects/nativescript-mqtt/demo/platforms/ios/Pods/PocketSocket/PocketSocket/PSWebSocketDriver.m:170

9 0x0000000103ef7244 in __20-[PSWebSocket send:]_block_invoke at /Users/paulmcgougan/Projects/nativescript-mqtt/demo/platforms/ios/Pods/PocketSocket/PocketSocket/PSWebSocket.m:242

Thread 15: EXC_BAD_ACCESS (code=257, address=0x590000000104701b)

coolsun commented 3 years ago

I have seen the same error. A silent crash on connect or subscribe. Is there a workaround?

Thread 34: EXC_BAD_ACCESS (code=EXC_I386_GPFLT)

if([payload length] < 126) { <<-- crashed here. headerBytes[1] |= [payload length]; } else if([payload length] <= UINT16_MAX) { headerBytes[1] |= 126;

Is there an ETA for a fix? We are pending on this issue to an IOT app production release of mqtt features.

edusperoni commented 3 years ago

This is an issue with nativescript-websockets (https://github.com/nathanaela/nativescript-websockets).

Unfortunately it uses a fairly old websocket implementation (PocketSocket), and there doesn't seem to be any new implementation that exposes Objective C bindings. There's Starscream (https://github.com/daltoniam/starscream) that's swift only and they refuse to add Objective C bindings (https://github.com/daltoniam/Starscream/pull/626).

We could also use the ReactNative websocket implementation (https://github.com/facebook/react-native/blob/dc80b2dcb52fadec6a573a9dd1824393f8c29fdc/Libraries/WebSocket/RCTSRWebSocket.m)

The alternative would be use a native iOS MQTT library and mimic the js MQTT implementation.

I don't have a fix for this, and I'm not confident in my Objective C skills for the job, but I'll gladly accept a PR and I'm sure one would also be gladly accepted at the nativescript-websockets plugin.

kryptus36 commented 3 years ago

There is a PR here: https://github.com/NathanaelA/nativescript-websockets/pull/82

But I don't know if it fixes the issue.

edusperoni commented 3 years ago

@kryptus36 That's interesting! I really want to provide a websocket polyfill to NativeScript, so I might take a look at that implementation.

Those imports are old, though, but you can try to update them and package the library and see if that works for you.

coolsun commented 3 years ago

@edusperoni Thanks very much for your quick response. I hope NathanaelA or someone will come up a native iOS websocket implementation to replace the PocketSocket soon.

kryptus36 commented 3 years ago

@kryptus36 That's interesting! I really want to provide a websocket polyfill to NativeScript, so I might take a look at that implementation.

Those imports are old, though, but you can try to update them and package the library and see if that works for you.

Unfortunately I don't think I have enough of the prerequisite knowledge to pull it off. But I do need it - I'm willing to put a bounty on it if it would speed things up. I don't know how to do that either, but throwing it out there.

kryptus36 commented 3 years ago

@edusperoni is there a way I can contact you directly?

edusperoni commented 3 years ago

@kryptus36 you can find me on the NS slack or discord (on discord look for users in the TSC role). If you want you can send me an email on my Github handle at Gmail

coolsun commented 3 years ago

@kryptus36 you can find me on the NS slack or discord (on discord look for users in the TSC role). If you want you can send me an email on my Github handle at Gmail

I am hoping this can be resolved soon. We are temporarily using Android phones since they work seamlessly. Please let me know if there is anything I could help with.

NathanaelA commented 2 years ago

Just a FYI everyone in this thread, I will be releasing a new version of the NativeScript-websockets in the next couple days that implements using Apple Native Websockets on Ios 13 and higher. It will still use PocketSocket on ios 12 and before...

coolsun commented 2 years ago

@NathanaelA, great news! Thank you very much! @edusperoni, could you switch to the new @master-technology/websockets asap? Thanks! https://www.npmjs.com/package/@master.technology/websockets

kryptus36 commented 2 years ago

@NathanaelA thank you! Question: what does that mean for ios users on older phones? Should we expect differences in functionality or is it just an implementation detail?

NathanaelA commented 2 years ago

@kryptus36 - On older iOS version (12 and before) it still uses PocketSocket as only 13+ has the native sockets. So the above issue would still be present on iOS 12 and below.

The only way to actually fix it on iOS 12 and before would be to replace the PocketSocket with a different library. I have looked at a couple other libraries but each of them would still take some time to implement. Unless a company/person wanted to do a PR or sponsor an update for me to replace the PocketSocket with a different native implementation, this is VERY unlikely to happen.

I honestly was very tempted just to drop iOS 12 and before support, but with it having about 8% of the market, I decided it still was still valuable to leave it in the new version even if it isn't perfect.

mcgouganp commented 2 years ago

@edusperoni Will you be changing to this new websockets release?

edusperoni commented 2 years ago

@mcgouganp I can bump the version here, but you should be able to install the new websockets version in your project and my plugin should pick it up

mcgouganp commented 2 years ago

@mcgouganp I can bump the version here, but you should be able to install the new websockets version in your project and my plugin should pick it up

Will that still work even though the package has been renamed from nativescript-websockets to @master.technology/websockets ?

edusperoni commented 2 years ago

I didn't know that, haha, I'll publish a new version. In the meantime you can use webpack resolve alias to rename the imports from the old package to the new one

mcgouganp commented 2 years ago

I didn't know that, haha, I'll publish a new version. In the meantime you can use webpack resolve alias to rename the imports from the old package to the new one

I have tried that using the demo app but the shim code in the new version of websockets gives an error which I haven't been able to solve, so I will wait for your new version.

ERROR in /Users/paulmcgougan/Projects/nativescript-mqtt-2/src/node_modules/@master.technology/websockets/websockets-base.js 21:4
Module parse failed: 'return' outside of function (21:4)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
| if (parseFloat(UIDevice.currentDevice.systemVersion) < 13.0) {
|     module.exports = require("./websockets-pocketsocket");
>     return;
| }
| 
coolsun commented 2 years ago

@edusperoni, hope we can get the update soon. Our customer is still waiting. Meanwhile, they are using the android app instead of iOS app for all MQTT features. Is there any estimated ETA? Thanks!

edusperoni commented 2 years ago

Please try chaining the webpack config with the following:

config.resolve.alias.set('nativescript-websockets', require.resolve('@master-technology/websockets'));

I'll update it when I have the time, but you can open a PR if you'd like.

kryptus36 commented 2 years ago

I gave a shot at creating a PR because the webpack method above didn't work (or I didn't know how to apply it?)

Switching websockets was easy, I just changed the dependency in package.json and the require line in paho-mqtt.js. I was able to get my project to work using the local file.

Where I failed was in trying to update the demo app. The new webpack config is failing and I don't know how to fix it.

Unable to apply changes on device: emulator-5554. Error is: spawn ./gradlew ENOENT.
(node:2798434) UnhandledPromiseRejectionWarning: RpcIpcMessagePortClosedError: Cannot send the message - the message port has been closed for the process 2798434.
    at /home/nick/Projects/node/nativescript-mqtt/demo/node_modules/fork-ts-checker-webpack-plugin/lib/rpc/rpc-ipc/RpcIpcMessagePort.js:47:47
    at processTicksAndRejections (internal/process/task_queues.js:81:21)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:2798434) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:2798434) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
(node:2798434) UnhandledPromiseRejectionWarning: RpcIpcMessagePortClosedError: Cannot send the message - the message port has been closed for the process 2798434.
    at /home/nick/Projects/node/nativescript-mqtt/demo/node_modules/fork-ts-checker-webpack-plugin/lib/rpc/rpc-ipc/RpcIpcMessagePort.js:47:47
    at processTicksAndRejections (internal/process/task_queues.js:81:21)
(node:2798434) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
edusperoni commented 2 years ago

@kryptus36 you can ignore updating the demo app :)

kryptus36 commented 2 years ago

Well, I have to throw in the towel. After switching it over on iOS I went from intermittent crash to crashing every time. It works on Android. I just don't know.

kryptus36 commented 2 years ago

Is there any chance of getting this fixed soon? I haven't been able to release an update for my app in months and I'm unable to figure this out.

edusperoni commented 2 years ago

Please try: https://www.npmjs.com/package/@edusperoni/nativescript-mqtt (alpha version)

npm i @edusperoni/nativescript-mqtt@alpha

kryptus36 commented 2 years ago

Thanks for putting time into this. The paho-mqtt.js and paho-mqtt.d.ts files are missing. I tried replacing them and changing the require line to no avail. Can you commit those files and do another push?

edusperoni commented 2 years ago

@kryptus36 my bad try the latest alpha (@edusperoni/nativescript-mqtt@2.0.0-alpha.2)

kryptus36 commented 2 years ago

@edusperoni I'm getting the same crash I got when trying to create a PR. This is where I got stuck.

OS Version: iOS 14.4 (20D80)
Report Version: 104

Exception Type: EXC_CRASH (SIGABRT)
Crashed Thread: 7

Application Specific Information:
-[NSDataAdapter dataUsingEncoding:]: unrecognized selector sent to instance 0x600000e2cdb0

Thread 7 Crashed:
0   CoreFoundation                  0xfffe40731ae6      __exceptionPreprocess
1   libobjc.A.dylib                 0xfffe402e9e77      objc_exception_throw
2   CoreFoundation                  0xfffe407406f6      -[NSObject(NSObject) doesNotRecognizeSelector:]
3   CoreFoundation                  0xfffe40736035      ___forwarding___
4   CoreFoundation                  0xfffe40738067      __forwarding_prep_0___
5   CFNetwork                       0xfffe46c045e9      _CFHTTPServerResponseEnqueue
6   CFNetwork                       0xfffe46c017cd      _CFHTTPServerResponseEnqueue
7   CFNetwork                       0xfffe46c043ce      _CFHTTPServerResponseEnqueue
8   libdispatch.dylib               0xfffe4020832e      _dispatch_call_block_and_release
9   libdispatch.dylib               0xfffe40209507      _dispatch_client_callout
10  libdispatch.dylib               0xfffe4020f3f8      _dispatch_lane_serial_drain
11  libdispatch.dylib               0xfffe4020ffaa      _dispatch_lane_invoke
12  libdispatch.dylib               0xfffe4021a576      _dispatch_workloop_worker_thread
13  libsystem_pthread.dylib         0xfffec22cb498      _pthread_wqthread
14  libsystem_pthread.dylib         0xfffec22ca466      start_wqthread

Thread 0
0   NativeScript                    0x107484b50         v8::internal::(anonymous namespace)::GetPageTableInitializer
1   NativeScript                    0x107c445a0         Builtins_RecordWrite
2   NativeScript                    0x107c92858         Builtins_MapPrototypeSet
3   NativeScript                    0x107c4f16a         [inlined] Builtins_InterpreterEntryTrampoline
4   NativeScript                    0x107c4f16a         [inlined] Builtins_InterpreterEntryTrampoline
5   NativeScript                    0x107c4f16a         [inlined] Builtins_InterpreterEntryTrampoline
6   NativeScript                    0x107c4f16a         [inlined] Builtins_InterpreterEntryTrampoline
7   NativeScript                    0x107c4f16a         [inlined] Builtins_InterpreterEntryTrampoline
8   NativeScript                    0x107c4f16a         [inlined] Builtins_InterpreterEntryTrampoline
9   NativeScript                    0x107c4f16a         [inlined] Builtins_InterpreterEntryTrampoline
10  NativeScript                    0x107c4f16a         Builtins_InterpreterEntryTrampoline
11  NativeScript                    0x107c4d33b         Builtins_JSEntryTrampoline
12  NativeScript                    0x107c4d0c3         Builtins_JSEntry
13  NativeScript                    0x107686877         v8::internal::(anonymous namespace)::Invoke
14  NativeScript                    0x107685e53         v8::internal::Execution::Call
15  NativeScript                    0x1074989a5         v8::Function::Call
16  NativeScript                    0x107368c9d         tns::ArgConverter::MethodCallback
17  NativeScript                    0x107467de6         ffi_closure_unix64_inner
18  NativeScript                    0x10746906a         ffi_closure_unix64
19  libdispatch.dylib               0xfffe40209507      _dispatch_client_callout
20  libdispatch.dylib               0xfffe40215ff6      _dispatch_main_queue_callback_4CF
21  CoreFoundation                  0xfffe4069fdba      __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__
22  CoreFoundation                  0xfffe4069a63d      __CFRunLoopRun
23  CoreFoundation                  0xfffe406996d5      CFRunLoopRunSpecific
24  GraphicsServices                0xfffe584abdb2      GSEventRunModal
25  UIKitCore                       0xfffe48135cf6      -[UIApplication _run]
26  UIKitCore                       0xfffe4813aba7      UIApplicationMain
27  NativeScript                    0x107468ead         ffi_call_unix64
28  <unknown>                       0x6000029b68d0      <redacted>

Thread 1 name: com.apple.NSURLConnectionLoader
0   libsystem_kernel.dylib          0xfffec2254e7e      mach_msg_trap
1   CoreFoundation                  0xfffe4069f9bb      __CFRunLoopServiceMachPort
2   CoreFoundation                  0xfffe4069a0c4      __CFRunLoopRun
3   CoreFoundation                  0xfffe406996d5      CFRunLoopRunSpecific
4   CFNetwork                       0xfffe46c515bd      _CFURLStorageSessionCopyCache
5   Foundation                      0xfffe40f74e67      __NSThread__start__
6   libsystem_pthread.dylib         0xfffec22ce94f      _pthread_start
7   libsystem_pthread.dylib         0xfffec22ca47a      thread_start

Thread 2
0   libsystem_kernel.dylib          0xfffec22577b6      __semwait_signal
1   libsystem_c.dylib               0xfffe4017746d      sleep
2   Sentry                          0x108bfe28c         monitorCachedData
3   libsystem_pthread.dylib         0xfffec22ce94f      _pthread_start
4   libsystem_pthread.dylib         0xfffec22ca47a      thread_start

Thread 3 name: SentryCrash Exception Handler (Secondary)
0   libsystem_kernel.dylib          0xfffec2254e7e      mach_msg_trap
1   libsystem_kernel.dylib          0xfffec2273f17      thread_suspend
2   Sentry                          0x108c12fd0         handleExceptions
3   libsystem_pthread.dylib         0xfffec22ce94f      _pthread_start
4   libsystem_pthread.dylib         0xfffec22ca47a      thread_start

Thread 4 name: SentryCrash Exception Handler (Primary)
0   libsystem_kernel.dylib          0xfffec2254e7e      mach_msg_trap
1   Sentry                          0x108c13012         handleExceptions
2   libsystem_pthread.dylib         0xfffec22ce94f      _pthread_start
3   libsystem_pthread.dylib         0xfffec22ca47a      thread_start

Thread 5 name: com.apple.uikit.eventfetch-thread
0   libsystem_kernel.dylib          0xfffec2254e7e      mach_msg_trap
1   CoreFoundation                  0xfffe4069f9bb      __CFRunLoopServiceMachPort
2   CoreFoundation                  0xfffe4069a0c4      __CFRunLoopRun
3   CoreFoundation                  0xfffe406996d5      CFRunLoopRunSpecific
4   Foundation                      0xfffe40f4c7b8      -[NSRunLoop(NSRunLoop) runMode:beforeDate:]
5   Foundation                      0xfffe40f4ca27      -[NSRunLoop(NSRunLoop) runUntilDate:]
6   UIKitCore                       0xfffe481ed074      -[UIEventFetcher threadMain]
7   Foundation                      0xfffe40f74e67      __NSThread__start__
8   libsystem_pthread.dylib         0xfffec22ce94f      _pthread_start
9   libsystem_pthread.dylib         0xfffec22ca47a      thread_start

Thread 6
0   libsystem_pthread.dylib         0xfffec22ca458      start_wqthread

Thread 8
0   libsystem_kernel.dylib          0xfffec22579be      __guarded_open_np
1   libsqlite3.dylib                0xfffe43801688      robust_open2
2   libsqlite3.dylib                0xfffe437cfbca      unixOpen
3   libsqlite3.dylib                0xfffe43814043      pager_write
4   libsqlite3.dylib                0xfffe4383ac45      btreeOverwriteContent
5   libsqlite3.dylib                0xfffe4383757d      btreeOverwriteCell
6   libsqlite3.dylib                0xfffe438309b8      sqlite3BtreeInsert
7   libsqlite3.dylib                0xfffe43828f1e      sqlite3VdbeExec
8   libsqlite3.dylib                0xfffe437d158d      sqlite3_step
9   bingoplus                       0x205c569f9         -[APMSqliteStore executeSQLStatement:error:]
10  bingoplus                       0x205c54efb         -[APMSqliteStore updateRecord:inTableWithName:columnName:columnValue:error:]
11  bingoplus                       0x205c27d92         -[APMDatabase updateDataType:inTableWithName:columnName:columnValue:error:]
12  bingoplus                       0x205c1be05         -[APMDatabase updateDailyCounts:error:]
13  bingoplus                       0x205c69e85         __49-[APMMeasurement writeEventOnWorkerQueue:]_block_invoke
14  bingoplus                       0x205c56208         -[APMSqliteStore performTransactionWithError:block:]
15  bingoplus                       0x205c1aea4         -[APMDatabase performTransaction:]
16  bingoplus                       0x205c69bfe         -[APMMeasurement(Event) writeEventOnWorkerQueue:]
17  bingoplus                       0x205c69715         -[APMMeasurement(Event) handleEventOnWorkerQueue:]
18  bingoplus                       0x205c31e41         -[APMMeasurement logEventOnWorkerQueue:notifyEventListeners:]
19  bingoplus                       0x205c31d84         -[APMMeasurement logEventOnWorkerQueueWithOrigin:isPublicEvent:name:parameters:timestamp:enabled:ignoreEnabled:ignoreInterceptor:interceptor:addedScreenParameters:]
20  bingoplus                       0x205c31a7d         __151-[APMMeasurement logEventWithOrigin:isPublicEvent:name:parameters:timestamp:enabled:ignoreEnabled:ignoreInterceptor:interceptor:addedScreenParameters:]_block_invoke
21  bingoplus                       0x205c3f936         __51-[APMScheduler scheduleOnWorkerQueueBlockID:block:]_block_invoke
22  libdispatch.dylib               0xfffe4020832e      _dispatch_call_block_and_release
23  libdispatch.dylib               0xfffe40209507      _dispatch_client_callout
24  libdispatch.dylib               0xfffe4020f3f8      _dispatch_lane_serial_drain
25  libdispatch.dylib               0xfffe4020ff73      _dispatch_lane_invoke
26  libdispatch.dylib               0xfffe4021a576      _dispatch_workloop_worker_thread
27  libsystem_pthread.dylib         0xfffec22cb498      _pthread_wqthread
28  libsystem_pthread.dylib         0xfffec22ca466      start_wqthread

Thread 9
0   libsystem_kernel.dylib          0xfffec225653e      __workq_kernreturn
1   libsystem_pthread.dylib         0xfffec22ca466      start_wqthread

Thread 10
0   libsystem_pthread.dylib         0xfffec22ca458      start_wqthread

EOF
kryptus36 commented 2 years ago

@robertbruno did you test your patch? That was the first thing I tried - but your paho file still has require("nativescript-websockets"); in it, which will obviously fail.

And if you fix that, you'll end up at the stack trace I posted above.

I am now beyond desperate for a fix. @edusperoni I am willing to pay you for your time if we can get this prioritized.

Otherwise I may need to look at react native :(

edusperoni commented 2 years ago

@kryptus36 this will be solved by https://github.com/NathanaelA/nativescript-websockets/pull/98

in the meantime, you can use the latest @edusperoni/nativescript-mqtt with the attached tgz

master.technology-websockets-2.0.4-edusperoni.0.tar.gz

(if you have trouble rename from tar.gz to .tgz. github doesn't like the tgz extension)

robertbruno commented 2 years ago

@kryptus36 I'm sorry I haven't been able to make it work yet

kryptus36 commented 2 years ago

@edusperoni Sad to report I get a different crash. Man I wish I could be of more help but thi just means nothing to me.

OS Version: iOS 14.4 (20D80) Report Version: 104

Exception Type: EXC_BREAKPOINT (SIGTRAP) Crashed Thread: 0

Application Specific Information: XTUM

Thread 0 Crashed: 0 NativeScript 0x10c8e7893 v8::base::OS::Abort 1 NativeScript 0x10bffa774 v8::HandleScope::HandleScope 2 NativeScript 0x10bfc75a0 v8_inspector::JsV8InspectorClient::scheduleBreak 3 CoreFoundation 0xfffe406a011f CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK 4 CoreFoundation 0xfffe4069f533 CFRunLoopDoBlocks 5 CoreFoundation 0xfffe4069a5a4 CFRunLoopRun 6 CoreFoundation 0xfffe406996d5 CFRunLoopRunSpecific 7 GraphicsServices 0xfffe584abdb2 GSEventRunModal 8 UIKitCore 0xfffe48135cf6 -[UIApplication _run] 9 UIKitCore 0xfffe4813aba7 UIApplicationMain 10 NativeScript 0x10bfd8ead ffi_call_unix64 11 0x600001a479e0

Thread 1 0 libsystem_kernel.dylib 0xfffec225653e __workq_kernreturn 1 libsystem_pthread.dylib 0xfffec22ca466 start_wqthread

Thread 2 0 libsystem_kernel.dylib 0xfffec225653e __workq_kernreturn 1 libsystem_pthread.dylib 0xfffec22ca466 start_wqthread

Thread 3 0 libsystem_kernel.dylib 0xfffec225653e __workq_kernreturn 1 libsystem_pthread.dylib 0xfffec22ca466 start_wqthread

Thread 4 0 libsystem_kernel.dylib 0xfffec225653e __workq_kernreturn 1 libsystem_pthread.dylib 0xfffec22ca466 start_wqthread

Thread 5 name: com.apple.NSURLConnectionLoader 0 libsystem_kernel.dylib 0xfffec2254e7e mach_msg_trap 1 CoreFoundation 0xfffe4069f9bb CFRunLoopServiceMachPort 2 CoreFoundation 0xfffe4069a0c4 CFRunLoopRun 3 CoreFoundation 0xfffe406996d5 CFRunLoopRunSpecific 4 CFNetwork 0xfffe46c515bd _CFURLStorageSessionCopyCache 5 Foundation 0xfffe40f74e67 NSThreadstart__ 6 libsystem_pthread.dylib 0xfffec22ce94f _pthread_start 7 libsystem_pthread.dylib 0xfffec22ca47a thread_start

Thread 6 0 libsystem_kernel.dylib 0xfffec22577b6 __semwait_signal 1 libsystem_c.dylib 0xfffe4017746d sleep 2 Sentry 0x10d76e28c monitorCachedData 3 libsystem_pthread.dylib 0xfffec22ce94f _pthread_start 4 libsystem_pthread.dylib 0xfffec22ca47a thread_start

Thread 7 name: SentryCrash Exception Handler (Secondary) 0 libsystem_kernel.dylib 0xfffec2254e7e mach_msg_trap 1 Sentry 0x10d783012 handleExceptions 2 libsystem_pthread.dylib 0xfffec22ce94f _pthread_start 3 libsystem_pthread.dylib 0xfffec22ca47a thread_start

Thread 9 name: com.apple.uikit.eventfetch-thread 0 libsystem_kernel.dylib 0xfffec2254e7e mach_msg_trap 1 CoreFoundation 0xfffe4069f9bb CFRunLoopServiceMachPort 2 CoreFoundation 0xfffe4069a0c4 CFRunLoopRun 3 CoreFoundation 0xfffe406996d5 CFRunLoopRunSpecific 4 Foundation 0xfffe40f4c7b8 -[NSRunLoop(NSRunLoop) runMode:beforeDate:] 5 Foundation 0xfffe40f4ca27 -[NSRunLoop(NSRunLoop) runUntilDate:] 6 UIKitCore 0xfffe481ed074 -[UIEventFetcher threadMain] 7 Foundation 0xfffe40f74e67 NSThreadstart__ 8 libsystem_pthread.dylib 0xfffec22ce94f _pthread_start 9 libsystem_pthread.dylib 0xfffec22ca47a thread_start

Thread 10 0 libsystem_kernel.dylib 0xfffec225653e __workq_kernreturn 1 libsystem_pthread.dylib 0xfffec22ca466 start_wqthread

Thread 11 0 libsystem_kernel.dylib 0xfffec225653e __workq_kernreturn 1 libsystem_pthread.dylib 0xfffec22ca466 start_wqthread

Thread 12 0 libsystem_kernel.dylib 0xfffec225653e __workq_kernreturn 1 libsystem_pthread.dylib 0xfffec22ca466 start_wqthread

Thread 13 0 libsystem_kernel.dylib 0xfffec2257b3a fsync 1 libsqlite3.dylib 0xfffe437d5764 sqlite3PagerCommitPhaseOne 2 libsqlite3.dylib 0xfffe437d5a32 sqlite3BtreeCommitPhaseOne 3 libsqlite3.dylib 0xfffe438184fc sqlite3VdbeHalt 4 libsqlite3.dylib 0xfffe4382de80 sqlite3VdbeExec 5 libsqlite3.dylib 0xfffe437d158d sqlite3_step 6 bingoplus 0x20a7c69f9 -[APMSqliteStore executeSQLStatement:error:] 7 bingoplus 0x20a7c697b -[APMSqliteStore executeSQL:error:] 8 bingoplus 0x20a7c3a0f -[APMSqliteStore ensureTableWithName:createSQL:requiredColumnNames:addOnColumns:error:] 9 bingoplus 0x20a7c2a1d -[APMSqliteStore ensureTableWithName:elementaryColumnInfo:addOnColumnInfo:error:] 10 bingoplus 0x20a7c3505 -[APMSqliteStore ensureTableWithName:elementaryColumnInfo:addOnColumnInfo:modifyColumnInfo:error:] 11 bingoplus 0x20a797177 -[APMDatabase ensureAllTables] 12 bingoplus 0x20a795641 -[APMDatabase initializeDatabaseResourcesWithContext:databasePath:error:] 13 bingoplus 0x20a78ad81 -[APMDatabase initWithDatabaseName:persistedConfig:error:] 14 bingoplus 0x20a79cd56 47-[APMMeasurement startMeasurementOnWorkerQueue]_block_invoke 15 bingoplus 0x20a79c646 -[APMMeasurement startMeasurementOnWorkerQueue] 16 bingoplus 0x20a79bfcf -[APMMeasurement setEnabledOnWorkerQueue:] 17 bingoplus 0x20a79be91 29-[APMMeasurement setEnabled:]_block_invoke 18 bingoplus 0x20a7af936 __51-[APMScheduler scheduleOnWorkerQueueBlockID:block:]_block_invoke 19 libdispatch.dylib 0xfffe4020832e _dispatch_call_block_and_release 20 libdispatch.dylib 0xfffe40209507 _dispatch_client_callout 21 libdispatch.dylib 0xfffe4020f3f8 _dispatch_lane_serial_drain 22 libdispatch.dylib 0xfffe4020ff73 _dispatch_lane_invoke 23 libdispatch.dylib 0xfffe4021a576 _dispatch_workloop_worker_thread 24 libsystem_pthread.dylib 0xfffec22cb498 _pthread_wqthread 25 libsystem_pthread.dylib 0xfffec22ca466 start_wqthread

Thread 14 0 libsystem_kernel.dylib 0xfffec225653e __workq_kernreturn 1 libsystem_pthread.dylib 0xfffec22ca466 start_wqthread

kryptus36 commented 2 years ago

@edusperoni Turns out that crash is unrelated. I will test further and report back!

kryptus36 commented 2 years ago

It seems this is indeed fixed. Thank you @edusperoni and @NathanaelA I will be requesting my company to make a donation to each of you. It would be great if you could push these latest versions out to npm.

phenric commented 2 years ago

I didn't know that, haha, I'll publish a new version. In the meantime you can use webpack resolve alias to rename the imports from the old package to the new one

I have tried that using the demo app but the shim code in the new version of websockets gives an error which I haven't been able to solve, so I will wait for your new version.

ERROR in /Users/paulmcgougan/Projects/nativescript-mqtt-2/src/node_modules/@master.technology/websockets/websockets-base.js 21:4
Module parse failed: 'return' outside of function (21:4)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
| if (parseFloat(UIDevice.currentDevice.systemVersion) < 13.0) {
|     module.exports = require("./websockets-pocketsocket");
>     return;
| }
| 

@mcgouganp Did you find a fix for your issue? I've the same as you. Thank you :)