Skip to content

fix(ios): always invoke WebKit completion handlers - #32

Open
NathanWalker wants to merge 1 commit into
nativescript-community:masterfrom
NathanWalker:fix/ios-uncalled-completion-handlers
Open

fix(ios): always invoke WebKit completion handlers#32
NathanWalker wants to merge 1 commit into
nativescript-community:masterfrom
NathanWalker:fix/ios-uncalled-completion-handlers

Conversation

@NathanWalker

Copy link
Copy Markdown
Member

WKWebView contains every decision/completion handler in a CompletionHandlerCallChecker whose destructor raises an ObjC exception if the handler was never called. Under NativeScript the block is owned by a JS wrapper, so the exception is thrown from inside a later V8 GC and aborts the app with SIGABRT far away from the code that dropped the handler.

Three paths never called their handler:

  • decidePolicyForNavigationAction: the Cancel call sat inside an if (Trace.isEnabled()) block, so cancelling a navigation from shouldOverrideUrlLoading leaked the handler in every build with tracing off. The !url early return leaked it too.
  • runJavaScriptAlert/Confirm/TextInputPanel: _webAlert/_webConfirm/ _webPrompt return false when the app registers no listener, and the missing-owner path returned early — both left the handler uncalled, so any page calling alert()/confirm()/prompt() could abort the app.

WKWebView wraps every decision/completion handler in a
CompletionHandlerCallChecker whose destructor raises an ObjC exception if the
handler was never called. Under NativeScript the block is owned by a JS
wrapper, so the exception is thrown from inside a later V8 GC and aborts the
app with SIGABRT far away from the code that dropped the handler.

Three paths never called their handler:

- decidePolicyForNavigationAction: the Cancel call sat inside an
  `if (Trace.isEnabled())` block, so cancelling a navigation from
  shouldOverrideUrlLoading leaked the handler in every build with tracing off.
  The `!url` early return leaked it too.
- runJavaScriptAlert/Confirm/TextInputPanel: `_webAlert`/`_webConfirm`/
  `_webPrompt` return false when the app registers no listener, and the
  missing-owner path returned early — both left the handler uncalled, so any
  page calling alert()/confirm()/prompt() could abort the app.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant