Commit 72773a86 by kimvde Committed by Ian Baker

Avoid sending message on dead thread

PiperOrigin-RevId: 493040714
parent 656b346e
...@@ -200,6 +200,9 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull; ...@@ -200,6 +200,9 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
} }
public void cancel() { public void cancel() {
if (released) {
return;
}
internalHandler internalHandler
.obtainMessage( .obtainMessage(
MSG_END, END_REASON_CANCELLED, /* unused */ 0, /* transformationException */ null) MSG_END, END_REASON_CANCELLED, /* unused */ 0, /* transformationException */ null)
...@@ -333,6 +336,9 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull; ...@@ -333,6 +336,9 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
releaseTransformationException = TransformationException.createForUnexpected(e); releaseTransformationException = TransformationException.createForUnexpected(e);
cancelException = e; cancelException = e;
} }
// Quit thread lazily so that all events that got triggered when releasing the AssetLoader are
// still delivered.
internalHandler.post(internalHandlerThread::quitSafely);
} }
if (!forCancellation) { if (!forCancellation) {
...@@ -352,7 +358,6 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull; ...@@ -352,7 +358,6 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
} }
} }
internalHandlerThread.quitSafely();
cancellingConditionVariable.open(); cancellingConditionVariable.open();
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment