Uh oh!
There was an error while loading. Please reload this page.
[Android][WebView] onShouldStartLoadWithRequest callback - #6478
Conversation
facebook-github-bot
commented
Mar 16, 2016
243054f to
d9e336bComparefacebook-github-bot
commented
Mar 16, 2016
@pglotov updated the pull request. |
jordaaash
commented
Mar 16, 2016
I love you so much right now. |
ide
commented
Mar 16, 2016
cc @astreet this PR introduces synchronous JS execution by allowing the UI thread to invoke JSC. CCing you since you wrote the Worker implementation. Based on my experience with multicore JSC, calling into the same JSContext from two threads is going to introduce race conditions within JS itself since JSC will try to concurrently interleave two separate JS calls. @pglotov I don't think this approach is going to work. If the WebView method needs to be synchronous, you should queue up the JS command to be run on the JS thread and then block the UI thread until the JS command is processed. |
There was a problem hiding this comment.
no-extra-bind: The function binding is unnecessary.
There was a problem hiding this comment.
no-extra-bind: The function binding is unnecessary.
pglotov
commented
Mar 16, 2016
@ide Actually it synchronously calls Java from JS thread. UI thread sends an (async) event to JS and blocks. JS processes the event and posts result into Java object (synchronously), unblocking UI thread. Race conditions in Java world can be dealt with. |
dmmiller
commented
Mar 16, 2016
Can you look at how iOS does this in WebView.ios.js? Also, would be nice if it had the same property name as in ios as well. Have you checked how this works for back/forward and history? Also shouldOverrideUrlLoading is not called in all instances. For instance, not on the initial load, nor when you explicitly tell the WebView to load a URL, only on link clicks which may be good enough. |
pglotov
commented
Mar 16, 2016
@dmmiller Yes I looked at iOS |
d9e336b to
f497da8Comparefacebook-github-bot
commented
Mar 16, 2016
@pglotov updated the pull request. |
| UIManager.dispatchViewManagerCommandSync( | ||
| this.getWebViewHandle(), | ||
| UIManager.RCTWebView.Commands.shouldOverrideWithResult, | ||
| [shouldOverride] |
There was a problem hiding this comment.
no-extra-bind: The function binding is unnecessary.
ide
commented
Mar 16, 2016
@pglotov ah sorry I must have misread what is going on |
f497da8 to
11385baComparefacebook-github-bot
commented
Mar 17, 2016
@pglotov updated the pull request. |
11385ba to
39a04bbComparefacebook-github-bot
commented
Mar 17, 2016
@pglotov updated the pull request. |
39a04bb to
9c4132aComparefacebook-github-bot
commented
Mar 17, 2016
@pglotov updated the pull request. |
pglotov
commented
Mar 17, 2016
@davidaurelio Thanks, made changes. |
davidaurelio
commented
Mar 17, 2016
great, thank you! |
There was a problem hiding this comment.
Thanks for cleaning this, but this is really orthagonal. Want to put up a quick PR to fix these and then I can accept and then this one will be easier to read?
There was a problem hiding this comment.
Sure, will do it later today.
dmmiller
commented
Mar 17, 2016
This question of whether we want to allow synchronous communication this way is pretty big. I'd like @andreicoman11 and @astreet to weigh in on it. |
younthu
commented
Jan 3, 2017
Strong need this. |
evanidul
commented
Feb 1, 2017
+1 |
astreet
commented
Feb 1, 2017
Like I mentioned above, I think a reasonable solution for the majority of cases would be to add a prop to WebView which is an array of regex's of urls to block synchronously. We would also want to add a new event for WebViews to be sent to JS when a URL is blocked this way so that JS can respond appropriately. Unfortunately, this isn't something we have a need for at FB so it's going to be up to an external contributor working on it, I can help review the code and offer advice. |
younthu
commented
Feb 2, 2017
@astreet , i just implemented it in our project with the regex prop way you described, i will try to extract those code out and send a pr to the FB, hope it help others. Please help to review it then, Thanks. |
mattiashalldin
commented
May 15, 2017
When will onShouldStartLoadWithRequest be available for Android? |
zheng-liu-seattle
commented
May 22, 2017
+1 need this. |
coyer
commented
May 27, 2017
+1 need this |
2 similar comments
caigehui
commented
Jul 17, 2017
+1 need this |
Livyli
commented
Aug 15, 2017
+1 need this |
ybolaris
commented
Sep 26, 2017
+1 |
4 similar comments
miguelocarvajal
commented
Oct 3, 2017
+1 |
tourze
commented
Oct 16, 2017
+1 |
kyangy
commented
Nov 10, 2017
+1 |
stanleycyang
commented
Nov 21, 2017
+1 |
Without |
+1 we need this |
MikePodgorniy
commented
Dec 7, 2017
+1 |
11 similar comments
punksta
commented
Jan 8, 2018
+1 |
ghost
commented
Jan 29, 2018
+1 |
shashankwadi
commented
Jan 29, 2018
+1 |
pulkitsharma99
commented
Jan 29, 2018
+1 |
pramodinwadi
commented
Jan 29, 2018
+1 |
akhilwadi
commented
Jan 29, 2018
+1 |
manjeetwadi
commented
Jan 29, 2018
+1 |
simranjeet-sawhney
commented
Jan 29, 2018
+1 |
rschef
commented
Mar 26, 2018
+1 |
prademak
commented
Mar 27, 2018
+1 |
SanlinBlackball
commented
Apr 19, 2018
+1 |
iamarkdev
commented
May 8, 2018
In the meantime, there is a pending PR on the |
This PR implements
onShouldStartLoadWithRequestcallback for WebView on Android. Similar to iOS approach in PR#3643.