-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Android sync java on should start load with request #8
base: master
Are you sure you want to change the base?
Conversation
android/src/main/java/com/reactnativecommunity/webview/RNCWebViewModule.java
Outdated
Show resolved
Hide resolved
android/src/main/java/com/reactnativecommunity/webview/RNCWebViewManager.java
Outdated
Show resolved
Hide resolved
|
||
if (jsContext.get() != 0 && rncWebView.mCatalystInstance != null) { | ||
final Pair<Integer, AtomicReference<RNCWebViewModule.ShouldOverrideUrlLoadingLock.ShouldOverrideCallbackState>> lock = RNCWebViewModule.shouldOverrideUrlLoadingLock.getNewLock(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd break out all this logic inside this if statement to another method so that the overall structure of shouldOverrideUrlLoading is very easy to understand.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't agree that this would help much (not a fan of extraction into a function just cause... especially if it's not reusable), maybe let's see where the other changes take it first.
android/src/main/java/com/reactnativecommunity/webview/RNCWebViewManager.java
Outdated
Show resolved
Hide resolved
android/src/main/java/com/reactnativecommunity/webview/RNCWebViewManager.java
Outdated
Show resolved
Hide resolved
android/src/main/java/com/reactnativecommunity/webview/RNCWebViewManager.java
Outdated
Show resolved
Hide resolved
@@ -76,6 +76,7 @@ class WebView extends React.Component<AndroidWebViewProps, State> { | |||
lastErrorEvent: null, | |||
}; | |||
|
|||
onShouldStartLoadWithRequest: ReturnType<typeof createOnShouldStartLoadWithRequest> | null = null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps rename things in this file to make it more clear to the reader that this is distinct? It's kind of confusing the way things are written now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll play with it and see how much better I can make it.
android/src/main/java/com/reactnativecommunity/webview/RNCWebViewManager.java
Outdated
Show resolved
Hide resolved
android/src/main/java/com/reactnativecommunity/webview/RNCWebViewManager.java
Outdated
Show resolved
Hide resolved
android/src/main/java/com/reactnativecommunity/webview/RNCWebViewManager.java
Outdated
Show resolved
Hide resolved
|
||
if (jsContext.get() != 0 && rncWebView.mCatalystInstance != null) { | ||
final Pair<Integer, AtomicReference<RNCWebViewModule.ShouldOverrideUrlLoadingLock.ShouldOverrideCallbackState>> lock = RNCWebViewModule.shouldOverrideUrlLoadingLock.getNewLock(); | ||
if (! isJsDebugging && rncWebView.mCatalystInstance != null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: in Java, we don't usually leave a space between ! and variable.
* Add androidLayerType as a prop * Deprecate "androidHardwareAccelerationDisabled" prop * Update reference Co-authored-by: Olivia Caraiman <olcaraim@microsoft.com>
# [10.8.0](react-native-webview/react-native-webview@v10.7.0...v10.8.0) (2020-08-24) ### Features * **android:** Add androidLayerType as prop ([react-native-webview#1588](react-native-webview#1588)) ([9ffca8f](react-native-webview@9ffca8f))
This solves a class of issues when the WebView loses "context" that a subsequent page load is the same as what was attempted to be loaded previously. This solves a bug where a HTTP redirect in combination with history manipulations causes a user to be stuck and prevented from going back. Since WebView requests are allowed to happen normally, debugging the WebView and tracking redirects and page load initiators is more accurate and easier. This will also bypass bridge latency and provide a faster navigation. To do this, we must lock in the shouldOverrideUrlLoading callback and send an event to JS. Currently, this callback is ran on the main UI thread, of which we have no control over. This is problematic as using the bridge in most ways seems to require the main UI thread, which will cause a deadlock. However, using BatchedBridge for Java->JS and a synchronous method for JS->Java doesn't cause any problems. Additionally, it's been designed so that if WebView suddenly runs the callback on a different thread allowing for concurrency, it will continue to work.
07efafd
to
773a3a4
Compare
Hello 👋, this PR has been opened for more than 2 months with no activity on it. If you think this is a mistake please comment and ping a maintainer to get this merged ASAP! Thanks for contributing! You have 7 days until this gets closed automatically |
No description provided.