Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: libadblockplus-android-webview/src/org/adblockplus/libadblockplus/android/webview/AdblockWebView.java

Issue 29677555: Issue 6299 - Avoid main thread lock on URL loading (Closed)
Patch Set: Created Jan. 23, 2018, 6:12 a.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | libadblockplus-android/src/org/adblockplus/libadblockplus/android/SingleInstanceEngineProvider.java » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: libadblockplus-android-webview/src/org/adblockplus/libadblockplus/android/webview/AdblockWebView.java
diff --git a/libadblockplus-android-webview/src/org/adblockplus/libadblockplus/android/webview/AdblockWebView.java b/libadblockplus-android-webview/src/org/adblockplus/libadblockplus/android/webview/AdblockWebView.java
index e531e73d858ba2d31616a99a0613e6762737fa2c..f4b444423987bc8d5db07add45bf6429173d1762 100644
--- a/libadblockplus-android-webview/src/org/adblockplus/libadblockplus/android/webview/AdblockWebView.java
+++ b/libadblockplus-android-webview/src/org/adblockplus/libadblockplus/android/webview/AdblockWebView.java
@@ -105,7 +105,6 @@ public class AdblockWebView extends WebView
private WebViewClient intWebViewClient;
private Map<String, String> url2Referrer = Collections.synchronizedMap(new HashMap<String, String>());
private String url;
- private String domain;
private String injectJs;
private CountDownLatch elemHideLatch;
private String elemHideSelectorsString;
@@ -827,6 +826,10 @@ public class AdblockWebView extends WebView
// allow loading by returning null
return null;
}
+ else
+ {
+ provider.waitForReady();
+ }
if (isMainFrame)
{
@@ -977,6 +980,7 @@ public class AdblockWebView extends WebView
}
else
{
+ provider.waitForReady();
String[] referrers = new String[]
{
url
@@ -1008,13 +1012,22 @@ public class AdblockWebView extends WebView
}
}
- d("Requesting elemhide selectors from AdblockEngine for " + url + " in " + this);
- List<String> selectors = provider
- .getEngine()
- .getElementHidingSelectors(url, domain, referrers);
+ String domain = provider.getEngine().getFilterEngine().getHostFromURL(url);
+ if (domain == null)
anton 2018/01/23 06:14:10 Not sure if it can happen
+ {
+ e("Failed to extract domain from " + url);
+ selectorsString = EMPTY_ELEMHIDE_ARRAY_STRING;
+ }
+ else
+ {
+ d("Requesting elemhide selectors from AdblockEngine for " + url + " in " + this);
+ List<String> selectors = provider
+ .getEngine()
+ .getElementHidingSelectors(url, domain, referrers);
- d("Finished requesting elemhide selectors, got " + selectors.size() + " in " + this);
- selectorsString = Utils.stringListToJsonArray(selectors);
+ d("Finished requesting elemhide selectors, got " + selectors.size() + " in " + this);
+ selectorsString = Utils.stringListToJsonArray(selectors);
+ }
}
}
finally
@@ -1119,24 +1132,6 @@ public class AdblockWebView extends WebView
if (url != null)
{
- try
- {
- d("Waiting for adblock engine");
- provider.waitForReady();
-
- domain = provider.getEngine().getFilterEngine().getHostFromURL(url);
- if (domain == null)
- {
- throw new RuntimeException("Failed to extract domain from " + url);
- }
-
- d("Extracted domain " + domain + " from " + url);
- }
- catch (Throwable t)
- {
- e("Failed to extract domain from " + url, t);
- }
-
elemHideLatch = new CountDownLatch(1);
elemHideThread = new ElemHideThread(elemHideLatch);
elemHideThread.setFinishedRunnable(elemHideThreadFinishedRunnable);
« no previous file with comments | « no previous file | libadblockplus-android/src/org/adblockplus/libadblockplus/android/SingleInstanceEngineProvider.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld