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 29671561: Issue 6274 - ANR on cancelling elemhide thread for load error (Closed)
Patch Set: reversed logics (Jens comment) Created Jan. 17, 2018, 8:32 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 | no next file » | 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 5536696065bf2e3a6310dd9fa0ecfebede4a857a..ea4cee1e201af14de44c43ee97bc2232dd7c6ee5 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
@@ -973,11 +973,13 @@ public class AdblockWebView extends WebView
{
private String selectorsString;
private CountDownLatch finishedLatch;
+ private AtomicBoolean isFinished;
private AtomicBoolean isCancelled;
public ElemHideThread(CountDownLatch finishedLatch)
{
this.finishedLatch = finishedLatch;
+ isFinished = new AtomicBoolean(false);
isCancelled = new AtomicBoolean(false);
}
@@ -1028,13 +1030,13 @@ public class AdblockWebView extends WebView
}
finally
{
- if (!isCancelled.get())
+ if (isCancelled.get())
{
- finish(selectorsString);
+ w("This thread is cancelled, exiting silently " + this);
}
else
{
- w("This thread is cancelled, exiting silently " + this);
+ finish(selectorsString);
}
}
}
@@ -1053,6 +1055,7 @@ public class AdblockWebView extends WebView
private void finish(String result)
{
+ isFinished.set(true);
d("Setting elemhide string " + result.length() + " bytes");
elemHideSelectorsString = result;
onFinished();
@@ -1072,9 +1075,15 @@ public class AdblockWebView extends WebView
public void cancel()
{
w("Cancelling elemhide thread " + this);
- isCancelled.set(true);
-
- finish(EMPTY_ELEMHIDE_ARRAY_STRING);
+ if (isFinished.get())
+ {
+ w("This thread is finished, exiting silently " + this);
+ }
+ else
+ {
+ isCancelled.set(true);
+ finish(EMPTY_ELEMHIDE_ARRAY_STRING);
+ }
}
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld