becvert/cordova-plugin-websocket-server

PSWebSocketDriver crash on iPad

chetan-prime opened this issue · 4 comments

I have an ios app running the websocket plugin.
While in normal usage I never see a problem, there is a particular case which causes this crash -

Exception Type:  EXC_BAD_ACCESS (SIGSEGV)
Exception Subtype: KERN_INVALID_ADDRESS at 0x0000000000000009
Exception Codes: 0x0000000000000001, 0x0000000000000009
VM Region Info: 0x9 is not in any region.  Bytes before following region: 4373725175
      REGION TYPE                 START - END      [ VSIZE] PRT/MAX SHRMOD  REGION DETAIL
      UNUSED SPACE AT START
--->  
      __TEXT                   104b1c000-104b20000 [   16K] r-x/r-x SM=COW  ...Prompter Plus
Exception Note:  EXC_CORPSE_NOTIFY
Terminating Process: exc handler [1171]
Triggered by Thread:  14

Thread 14 name:
Thread 14 Crashed:
0   dvPrompter Plus               	0x0000000104c2bb74 -[PSWebSocketDriver readBytes:maxLength:error:] + 1112948 (PSWebSocketDriver.m:682)
1   dvPrompter Plus               	0x0000000104c2b8d8 -[PSWebSocketDriver readBytes:maxLength:error:] + 1112280 (PSWebSocketDriver.m:670)
2   dvPrompter Plus               	0x0000000104c2a464 -[PSWebSocketDriver execute:maxLength:] + 1107044 (PSWebSocketDriver.m:146)
3   dvPrompter Plus               	0x0000000104c27cf4 -[PSWebSocket pumpInput] + 1096948 (PSWebSocket.m:363)
4   dvPrompter Plus               	0x0000000104c28f7c -[PSWebSocket stream:handleEvent:] + 1101692 (PSWebSocket.m:586)
5   CoreFoundation                	0x0000000184758de0 _signalEventSync + 216 (CFStream.c:626)
6   CoreFoundation                	0x0000000184775900 ___signalEventQueue_block_invoke + 28 (CFStream.c:646)
7   libdispatch.dylib             	0x000000018435e924 _dispatch_call_block_and_release + 32 (init.c:1517)
8   libdispatch.dylib             	0x0000000184360670 _dispatch_client_callout + 20 (object.m:560)
9   libdispatch.dylib             	0x0000000184367df4 _dispatch_lane_serial_drain + 672 (inline_internal.h:2601)
10  libdispatch.dylib             	0x0000000184368968 _dispatch_lane_invoke + 392 (queue.c:3937)
11  libdispatch.dylib             	0x00000001843731b8 _dispatch_workloop_worker_thread + 656 (queue.c:6727)
12  libsystem_pthread.dylib       	0x00000001f3f630f4 _pthread_wqthread + 288 (pthread.c:2599)
13  libsystem_pthread.dylib       	0x00000001f3f62e94 start_wqthread + 8

I even downloaded Pocketsocket from your repo and rebuild for ios12 but to no avail.
The crash occurs only when I create a webview for the external / secondary screen. I suspect somehow in iPad this causes a crash when the webview connects to websockt server running on localhost, android works fine. Even my iPhone6 works fine.
Somehow the crash is triggered only on iPad, and only with the webview websocket, it works fine through app webui on browser, which uses the same code, but connects on LAN IP instead of localhost.
I could send the full crashdump file if required.

I have updated the log above.
As we can see, it looks the ObjC code is attempting to access a null pointer and crashing

any news to this issue? I experience it also on iphone 13

@RFM69CW I don't remember exactly what I did, but I think I had to recompile the base websocket library from source and patch some of the code. Also, compilation target was bumped to 12.x
This was a long time back, here is the patch file against PocketSocket commit 63e016dbcbb404562c7b90660fa73173bb93ad84
pocketsocket-fix.zip

Ah thank you for the quick response. It looks like I can not rely on this plugin ;-) I am looking for a different solution.