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: Created Jan. 17, 2018, 7:11 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..f6522dd7c419797d0e77fdffbf65d7fff05ef04b 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);
}
@@ -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())
jens 2018/01/17 08:28:43 To make the if statement more readable, I would pr
anton 2018/01/17 08:33:55 Done. See patch set #2
+ {
+ isCancelled.set(true);
+ finish(EMPTY_ELEMHIDE_ARRAY_STRING);
+ }
+ else
+ {
+ w("This thread is finished, exiting silently " + this);
+ }
}
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld