[AW] check if native lib is loaded instead of initialized in nonembedded
WebViewApkApplication#initializeNative() only calls LibarayLoader#loadNow and doesn't call LibraryLoader#initialize() so it should check if the lib is loaded rather than checking if fully initialized. Bug: 1218923 Test: Manually force launch AwComponentUpdateService twice Change-Id: I47fb78e192f19be661c23f9dd1846c846a30b4e1 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2957308 Reviewed-by: Andrew Grieve <agrieve@chromium.org> Reviewed-by: Richard Coles <torne@chromium.org> Reviewed-by: Mugdha Lakhani <nator@chromium.org> Commit-Queue: Hazem Ashmawy <hazems@chromium.org> Cr-Commit-Position: refs/heads/master@{#893367}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
60bf506b11
commit
02c12d342e
android_webview/nonembedded/java/src/org/chromium/android_webview/nonembedded
base/android/java/src/org/chromium/base/library_loader
@@ -54,7 +54,7 @@ public class AwComponentUpdateService extends JobService {
|
|||||||
|
|
||||||
// TODO(http://crbug.com/1179297) look at doing this in a task on a background thread
|
// TODO(http://crbug.com/1179297) look at doing this in a task on a background thread
|
||||||
// instead of the main thread.
|
// instead of the main thread.
|
||||||
if (WebViewApkApplication.initializeNative()) {
|
if (WebViewApkApplication.ensureNativeLoaded()) {
|
||||||
setUnexpectedExit(true);
|
setUnexpectedExit(true);
|
||||||
final long startTime = SystemClock.uptimeMillis();
|
final long startTime = SystemClock.uptimeMillis();
|
||||||
// TODO(crbug.com/1171817) Once we can log UMA from native, remove the count parameter.
|
// TODO(crbug.com/1171817) Once we can log UMA from native, remove the count parameter.
|
||||||
|
@@ -48,7 +48,7 @@ public class LicenseContentProvider
|
|||||||
@Override
|
@Override
|
||||||
public void writeDataToPipe(
|
public void writeDataToPipe(
|
||||||
ParcelFileDescriptor output, Uri uri, String mimeType, Bundle opts, String filename) {
|
ParcelFileDescriptor output, Uri uri, String mimeType, Bundle opts, String filename) {
|
||||||
if (WebViewApkApplication.initializeNative()) {
|
if (WebViewApkApplication.ensureNativeLoaded()) {
|
||||||
CreditUtilsJni.get().writeCreditsHtml(output.detachFd());
|
CreditUtilsJni.get().writeCreditsHtml(output.detachFd());
|
||||||
} else {
|
} else {
|
||||||
// Missing native library means we're the webview stub and licenses are stored as an
|
// Missing native library means we're the webview stub and licenses are stored as an
|
||||||
|
@@ -143,9 +143,11 @@ public class WebViewApkApplication extends Application {
|
|||||||
* Performs minimal native library initialization required when running as a stand-alone APK.
|
* Performs minimal native library initialization required when running as a stand-alone APK.
|
||||||
* @return True if the library was loaded, false if running as webview stub.
|
* @return True if the library was loaded, false if running as webview stub.
|
||||||
*/
|
*/
|
||||||
static synchronized boolean initializeNative() {
|
static synchronized boolean ensureNativeLoaded() {
|
||||||
try {
|
try {
|
||||||
if (LibraryLoader.getInstance().isInitialized()) {
|
// TODO(https://crbug.com/1220862): Investigate calling LibraryLoader#initialize and
|
||||||
|
// LibraryLoader#isInitialized instead and document the findings.
|
||||||
|
if (LibraryLoader.getInstance().isLoaded()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
// Should not call LibraryLoader.initialize() since this will reset UmaRecorder
|
// Should not call LibraryLoader.initialize() since this will reset UmaRecorder
|
||||||
@@ -153,14 +155,14 @@ public class WebViewApkApplication extends Application {
|
|||||||
LibraryLoader.getInstance().setLibraryProcessType(
|
LibraryLoader.getInstance().setLibraryProcessType(
|
||||||
LibraryProcessType.PROCESS_WEBVIEW_NONEMBEDDED);
|
LibraryProcessType.PROCESS_WEBVIEW_NONEMBEDDED);
|
||||||
LibraryLoader.getInstance().loadNow();
|
LibraryLoader.getInstance().loadNow();
|
||||||
|
LibraryLoader.getInstance().switchCommandLineForWebView();
|
||||||
|
WebViewApkApplicationJni.get().initializeGlobalsAndResources();
|
||||||
|
return true;
|
||||||
} catch (Throwable unused) {
|
} catch (Throwable unused) {
|
||||||
// Happens for WebView Stub. Throws NoClassDefFoundError because of no
|
// Happens for WebView Stub. Throws NoClassDefFoundError because of no
|
||||||
// NativeLibraries.java being generated.
|
// NativeLibraries.java being generated.
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
LibraryLoader.getInstance().switchCommandLineForWebView();
|
|
||||||
WebViewApkApplicationJni.get().initializeGlobalsAndResources();
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@NativeMethods
|
@NativeMethods
|
||||||
|
@@ -498,11 +498,18 @@ public class LibraryLoader {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks whether the native library is fully loaded.
|
||||||
|
*/
|
||||||
|
public boolean isLoaded() {
|
||||||
|
return mLoadState == LoadState.LOADED;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks whether the native library is fully loaded and initialized.
|
* Checks whether the native library is fully loaded and initialized.
|
||||||
*/
|
*/
|
||||||
public boolean isInitialized() {
|
public boolean isInitialized() {
|
||||||
return mInitialized && mLoadState == LoadState.LOADED;
|
return mInitialized && isLoaded();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user