BlackWolf / Connichiwa

A framework for local multi-device web applications
15 stars 0 forks source link

WebThread Crash on opening websocket #59

Open BlackWolf opened 10 years ago

BlackWolf commented 10 years ago

About 5% of the time, when we try to establish a connection from device A to device B the WebThread will crash. The crash happens on the connecting device (A) and seems to happen after the websocket was established (because remoteDidConnect on CWWebApplication is called before the crash).

Not quite sure what triggers this, if it maybe is an iOS bug or whatever. The exact same issue seems to be described in http://stackoverflow.com/questions/23052484/ios-web-thread-stopped-when-using-websocket-in-uiwebview.

The stacktrace of the crashing thread is:

Thread 6 WebThread, Queue : (null)
#0  0x301563c4 in CFRelease ()
#1  0x301efb62 in __CFRunLoopTimerDeallocate ()
#2  0x30156126 in CFRelease ()
#3  0x301ceb50 in __CFArrayReleaseValues ()
#4  0x30156126 in CFRelease ()
#5  0x301eef10 in __CFRunLoopRun ()
#6  0x30159768 in CFRunLoopRunSpecific ()
#7  0x3015954a in CFRunLoopRunInMode ()
#8  0x3848cc4c in RunWebThread(void*) ()
#9  0x3afd8958 in _pthread_body ()
#10 0x3afd88ca in _pthread_start ()
#11 0x3afd6ae8 in thread_start ()
BlackWolf commented 10 years ago

Fun Fact: This just happened again, but this time on the device that became a remote device. The device that crashed was an iPhone both times. The connecting (master) device did not report anything unusual and shows the other device as connected. As this happend in or after CWRemoteLibraryManagers connectToServer:, I suppose this might be related to the load request of the remote library.

BlackWolf commented 10 years ago

Occured again, but with a slightly different callstack. Interestingly, the crash occured AFTER the first message was received by the web library.

Callstack:

Thread 6 WebThread, Queue : (null)
#0  0x3a9c6626 in objc_msgSend ()
#1  0x30156e96 in CFEqual ()
#2  0x30158230 in CFBasicHashAddValue ()
#3  0x3016a9ae in CFRunLoopAddTimer ()
#4  0x384aa580 in WebCore::setSharedTimerFireInterval(double) ()
#5  0x383ff790 in WebCore::timerFired(__CFRunLoopTimer*, void*) ()
#6  0x301f0f4e in __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ ()
#7  0x301f0b6a in __CFRunLoopDoTimer ()
#8  0x301eeef2 in __CFRunLoopRun ()
#9  0x30159768 in CFRunLoopRunSpecific ()
#10 0x3015954a in CFRunLoopRunInMode ()
#11 0x3848cc4c in RunWebThread(void*) ()
#12 0x3afd8958 in _pthread_body ()
#13 0x3afd88ca in _pthread_start ()

Log Output:

NATIVE    13:43:42.295 CWBluetoothManager.m:995 -- Checking URL http://192.168.1.102:8000/check 
NATIVE    13:43:42.623 CWBluetoothManager.m:1000 -- Found working URL: http://192.168.1.102:8000/check 
NATIVE    13:43:42.624 CWRemoteLibraryManager.m:44 -- !! SWITCHING INTO REMOTE STATE 
NATIVE    13:43:43.603 CWRemoteLibraryManager.m:182 -- Setting up Remote Context 
NATIVE    13:43:43.604 CWRemoteLibraryManager.m:202 -- Registering JS Callbacks 
NATIVE    13:43:43.604 CWRemoteLibraryManager.m:204 -- Connecting websocket 
NATIVE    13:43:43.920 CWRemoteLibraryManager.m:197 -- 13:43:43.919 -- message: {"type":"show","content":"<div id=\"distance_33ABF0F4-1A4A-487C-9F0A-FAB242C055E6\" class=\"distance\" style=\"background-attachment: scroll; background-clip: border-box; background-color: rgba(0, 0, 0, 0); background-image: none; background-origin: padding-box; background-size: auto; border: 0px none rgb(211, 211, 211); border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-collapse: separate; border-image-outset: 0px; border-image-repeat: stretch; border-image-slice: 100%; border-image-source: none; border-image-width: 1; border-top-left-radius: 0px; border-top-right-radius: 0px; bottom: auto; box-shadow: none; box-sizing: content-box; caption-side: top; clear: none; clip: auto; color: rgb(211, 211, 211); cursor: auto; direction: ltr; display: block; empty-cells: show; float: none; font-family: 'Helvetica Neue'; font-size: 80px; font-style: normal; font-variant: normal; font-weight: normal; height: 98px; image-rendering: auto; left: auto; letter-spacing: normal; line-height: normal; list-style: disc outside none; margin: 0px; max-height: none; max-width: none; min-height: 0px; min-width: 0px; opacity: 1; orphans: auto; outline: rgb(211, 211, 211) none 0px; outline-offset: 0px; overflow-wrap: normal; overflow: visible; padding: 0px; page-break-after: auto; page-break-before: auto; page-break-inside: auto; pointer-events: auto; position: static; resize: none; right: auto; speak: normal; table-layout: auto; tab-size: 8; text-align: center; text-decoration: none; text-indent: 0px; text-rendering: auto; text-shadow: none; text-overflow: clip; text-transform: none; top: auto; transition: all 0s ease 0s; -webkit-transition: all 0s ease 0s; unicode-bidi: normal; vertical-align: baseline; visibility: visible; white-space: normal; widows: auto; width: 320px; word-break: normal; word-spacing: 0px; word-wrap: normal; z-index: auto; zoom: 1; -webkit-animation: none 0s ease 0s 1 normal none; -webkit-animation-play-state: running; -webkit-appearance: none; -webkit-backface-visibility: visible; -webkit-background-clip: border-box; -webkit-background-composite: source-over; -webkit-background-origin: padding-box; -webkit-background-size: auto; -webkit-border-fit: border; border-spacing: 0px; -webkit-border-image: none; -webkit-box-align: stretch; -webkit-box-decoration-break: slice; -webkit-box-direction: normal; -webkit-box-flex: 0; -webkit-box-flex-group: 1; -webkit-box-lines: single; -webkit-box-ordinal-group: 1; -webkit-box-orient: horizontal; -webkit-box-pack: start; -webkit-box-reflect: none; -webkit-box-shadow: none; -webkit-clip-path: none; -webkit-color-correction: default; -webkit-column-break-after: auto; -webkit-column-break-before: auto; -webkit-column-break-inside: auto; -webkit-column-axis: auto; -webkit-column-count: auto; -webkit-column-gap: normal; -webkit-column-progression: normal; -webkit-column-rule-color: rgb(211, 211, 211); -webkit-column-rule-style: none; -webkit-column-rule-width: 0px; -webkit-column-span: none; -webkit-column-width: auto; -webkit-cursor-visibility: auto; -webkit-filter: none; -webkit-align-content: stretch; -webkit-align-items: stretch; -webkit-align-self: stretch; -webkit-flex: 0 1 auto; -webkit-flex-flow: row nowrap; -webkit-justify-content: flex-start; -webkit-font-kerning: auto; -webkit-font-smoothing: auto; -webkit-font-variant-ligatures: normal; -webkit-grid-auto-flow: none; -webkit-highlight: none; -webkit-hyphenate-character: auto; -webkit-hyphenate-limit-after: auto; -webkit-hyphenate-limit-before: auto; -webkit-hyphenate-limit-lines: no-limit; -webkit-hyphens: manual; -webkit-line-align: none; -webkit-line-box-contain: block inline replaced; -webkit-line-break: auto; -webkit-line-grid: none; -webkit-line-snap: none; -webkit-locale: auto; -webkit-margin-before-collapse: collapse; -webkit-margin-after-collapse: collapse; -webkit-marquee-direction: auto; -webkit-marquee-increment: 6px; -webkit-marquee-repetition: infinite; -webkit-marquee-style: scroll; -webkit-mask-box-image: none; -webkit-mask-box-image-outset: 0px; -webkit-mask-box-image-repeat: stretch; -webkit-mask-box-image-slice: 0 fill; -webkit-mask-box-image-source: none; -webkit-mask-box-image-width: auto; -webkit-mask: none 0% 0% / auto repeat border-box border-box; -webkit-mask-composite: source-over; -webkit-mask-size: auto; -webkit-nbsp-mode: normal; -webkit-order: 0; -webkit-perspective: none; -webkit-perspective-origin-x: 160px; -webkit-perspective-origin-y: 49px; -webkit-print-color-adjust: economy; -webkit-rtl-ordering: logical; -webkit-touch-callout: default; -webkit-composition-fill-color: rgba(175, 192, 227, 0.235294); -webkit-overflow-scrolling: auto; -webkit-tap-highlight-color: rgba(26, 26, 26, 0.301961); -webkit-text-combine: none; -webkit-text-decorations-in-effect: none; -webkit-text-emphasis-color: rgb(211, 211, 211); -webkit-text-emphasis-position: over; -webkit-text-emphasis-style: none; -webkit-text-fill-color: rgb(211, 211, 211); -webkit-text-orientation: vertical-right; -webkit-text-security: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-color: rgb(211, 211, 211); -webkit-text-stroke-width: 0px; -webkit-transform: none; -webkit-transform-origin: 160px 49px; -webkit-transform-style: flat; -webkit-user-drag: auto; -webkit-user-modify: read-only; -webkit-user-select: text; -webkit-writing-mode: horizontal-tb; -webkit-flow-into: none; -webkit-flow-from: none; -webkit-region-break-after: auto; -webkit-region-break-before: auto; -webkit-region-break-inside: auto; -webkit-region-fragment: auto; buffered-rendering: auto; clip-path: none; clip-rule: nonzero; mask: none; filter: none; flood-color: #000000; flood-opacity: 1; lighting-color: #ffffff; stop-color: #000000; stop-opacity: 1; color-interpolation: srgb; color-interpolation-filters: linearrgb; color-rendering: auto; fill: #000000; fill-opacity: 1; fill-rule: nonzero; marker-end: none; marker-mid: none; marker-start: none; mask-type: luminance; shape-rendering: auto; stroke: none; stroke-dasharray: none; stroke-dashoffset: 0px; stroke-linecap: butt; stroke-linejoin: miter; stroke-miterlimit: 4; stroke-opacity: 1; stroke-width: 1px; alignment-baseline: auto; baseline-shift: baseline; dominant-baseline: auto; kerning: 0px; text-anchor: start; writing-mode: lr-tb; glyph-orientation-horizontal: 0deg; glyph-orientation-vertical: auto; -webkit-svg-shadow: none; vector-effect: none; background-position: 0% 0%; background-repeat: repeat repeat;\">0.2m</div>","target":"33ABF0F4-1A4A-487C-9F0A-FAB242C055E6"} 
BlackWolf commented 10 years ago

I suppose it can be said that this ONLY occurs on my iPhone so far and it seems to happen after the first message of a new websocket connection was received (regardless of the message). This might indicate a devices-specific bug or an iOS 7.1 bug, as the iPad I am using for testing runs iOS 7.0.1 right now.