Skip to content
Snippets Groups Projects
Commit 15f9a7e6 authored by Mariam Ali's avatar Mariam Ali Committed by Chromium LUCI CQ
Browse files

[Clank][BrowsingDataModel] Destroy old model asynchronously

Due to slow model build, sometimes JNI framework hangs/crashes due to
attempting to destroy a model object as we're creating a new one.
This CL works around this issue by keeping a reference of the old model
and posting the destroy task so it doesn't conflict with the new model
creation callback.

Fixed: 370355422
Bug: b:254415177
Change-Id: I925ed5e649f02a894fefcccc4c4d6ba72e6d770e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5998871


Reviewed-by: default avatarChristian Dullweber <dullweber@chromium.org>
Auto-Submit: Mariam Ali <alimariam@google.com>
Commit-Queue: Mariam Ali <alimariam@google.com>
Code-Coverage: findit-for-me@appspot.gserviceaccount.com <findit-for-me@appspot.gserviceaccount.com>
Cr-Commit-Position: refs/heads/main@{#1378947}
parent 5ac3636c
No related branches found
No related tags found
No related merge requests found
......@@ -23,6 +23,8 @@ import org.chromium.base.CommandLine;
import org.chromium.base.IntentUtils;
import org.chromium.base.PackageManagerUtils;
import org.chromium.base.supplier.OneshotSupplier;
import org.chromium.base.task.PostTask;
import org.chromium.base.task.TaskTraits;
import org.chromium.build.BuildConfig;
import org.chromium.chrome.R;
import org.chromium.chrome.browser.LaunchIntentDispatcher;
......@@ -434,7 +436,13 @@ public class ChromeSiteSettingsDelegate implements SiteSettingsDelegate {
mProfile,
model -> {
if (mBrowsingDataModel != null) {
mBrowsingDataModel.destroy();
// Posting the task to destroy the model to avoid ANR hangs/crashes caused
// by sometimes slow model building and JNI deadlock.
// The old model reference needs to be captured before posting the destroy
// task to avoid crashing caused by destroying the new model instead of the
// old model.
BrowsingDataModel oldModel = mBrowsingDataModel;
PostTask.postTask(TaskTraits.UI_DEFAULT, oldModel::destroy);
}
mBrowsingDataModel = model;
callback.onResult(mBrowsingDataModel);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment