Finish attach appliation before creating app context
Creating the app context involves getting app resources from the app's apk. This operation could be blocked on an incremental fs and trigger the proc start timeout. While fixing this, I noticed that apps could also run code and block in AppComponentFactory#instantiateClassLoader, so moved the call to finishAttachApplication even earlier. It's probably worth re-thinking the AnR timeouts around proc starts, because currently, if the app blocks in instantiateClassLoader for instance, neither AnR timeout nor proc start timeout will trigger. For now, this fixes the test and keeps the behavior as close to the old behavior as possible. Test: atest CtsPackageManagerStatsHostTestCases:com.android.cts.packagemanager.stats.host.IncrementalAppErrorStatsTests#testAppCrashOnIncremental Bug: 261009296 Change-Id: Ic75a4e9d38a7c21d4a0b948d6fb26389723a80f6
This commit is contained in:
@@ -6715,6 +6715,13 @@ public final class ActivityThread extends ClientTransactionHandler
|
||||
ii = null;
|
||||
}
|
||||
|
||||
final IActivityManager mgr = ActivityManager.getService();
|
||||
try {
|
||||
mgr.finishAttachApplication(mStartSeq);
|
||||
} catch (RemoteException ex) {
|
||||
throw ex.rethrowFromSystemServer();
|
||||
}
|
||||
|
||||
final ContextImpl appContext = ContextImpl.createAppContext(this, data.info);
|
||||
mConfigurationController.updateLocaleListFromAppContext(appContext);
|
||||
|
||||
@@ -6783,13 +6790,6 @@ public final class ActivityThread extends ClientTransactionHandler
|
||||
final StrictMode.ThreadPolicy savedPolicy = StrictMode.allowThreadDiskWrites();
|
||||
final StrictMode.ThreadPolicy writesAllowedPolicy = StrictMode.getThreadPolicy();
|
||||
|
||||
final IActivityManager mgr = ActivityManager.getService();
|
||||
try {
|
||||
mgr.finishAttachApplication(mStartSeq);
|
||||
} catch (RemoteException ex) {
|
||||
throw ex.rethrowFromSystemServer();
|
||||
}
|
||||
|
||||
// Wait for debugger after we have notified the system to finish attach application
|
||||
if (data.debugMode != ApplicationThreadConstants.DEBUG_OFF) {
|
||||
// XXX should have option to change the port.
|
||||
|
||||
Reference in New Issue
Block a user