Repository navigation
iOS: callAsyncJavaScript module method for reply-in-one-hop calls - #19
Draft
artemlitch wants to merge 2 commits into
Draft
artemlitch wants to merge 2 commits into
artemlitch wants to merge 2 commits into
Conversation
…ge handler callAsyncJavaScript(viewTag, functionBody, argument) runs a function in the page and resolves with its string result, so a caller gets a reply without a postMessage and onMessage round trip. The ReactNativeWebViewFast handler delivers page messages through the module's onFastMessage emitter; it measured slower than onMessage and is unused. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
It measured slower than onMessage, so only the callAsyncJavaScript call path remains. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014HGrJetPUopRfPnfocezrH
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Shelved for later. Paired with a Rekindled draft PR that uses it.
Problem
Bookwise talks to the reader WebView through the portal gate. An RN-to-WebView call takes two hops. RN injects a script with
injectJavaScript. The page then answers withpostMessage, which reaches RN as a FabriconMessageevent.Change
RNCWebViewModule.callAsyncJavaScript(viewTag, functionBody, argument)runs a function in the page through WebKit'scallAsyncJavaScriptand resolves the TurboModule promise with the string it returns. The reply comes back with the call, so there is nopostMessageand noonMessageevent.RNCWebViewkeeps a weak tag-to-view registry so the module can find the view.callAsyncJavaScript(functionBody, argument), which finds the tag for you.Measurements
These are from a Release build of Bookwise on the iPhone 17 Pro simulator. Both columns already have the Rekindled log-batching fix (readwiseio/rekindled#13526), so only the transport differs.
I also tried a dedicated WebKit message handler that delivered page-to-RN messages through a TurboModule event emitter. It was slower than
onMessage, 8.5 ms against 7.4 ms for 200 events, so I removed it.Before merging
🤖 Generated with Claude Code
https://claude.ai/code/session_014HGrJetPUopRfPnfocezrH