Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
[Android][WebView] onShouldStartLoadWithRequest callback #6478
referenced this pull request
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.
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.
@dmmiller Yes I looked at iOS
Mar 16, 2016
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.