Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Android] Fix Headless Crash Tried to finish non-existent task with id #46497

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -169,18 +169,16 @@ public void run() {

/**
* Finish a JS task. Doesn't actually stop the task on the JS side, only removes it from the list
* of active tasks and notifies listeners. A task can only be finished once.
* of active tasks and notifies listeners.
*
* @param taskId the unique id returned by {@link #startTask}.
*/
public synchronized void finishTask(final int taskId) {
Assertions.assertCondition(
mActiveTasks.remove(taskId), "Tried to finish non-existent task with id " + taskId + ".");
Assertions.assertCondition(
mActiveTaskConfigs.remove(taskId) != null,
"Tried to remove non-existent task config with id " + taskId + ".");
boolean removed = mActiveTasks.remove(taskId);
mActiveTaskConfigs.remove(taskId);
removeTimeout(taskId);
UiThreadUtil.runOnUiThread(
if (removed) {
UiThreadUtil.runOnUiThread(
new Runnable() {
@Override
public void run() {
Expand All @@ -189,6 +187,7 @@ public void run() {
}
}
});
}
}

private void removeTimeout(int taskId) {
Expand Down
Loading