diff options
-rw-r--r-- | android_webview/lib/main/webview_entry_point.cc | 8 | ||||
-rw-r--r-- | content/browser/renderer_host/compositor_impl_android.cc | 20 |
2 files changed, 28 insertions, 0 deletions
diff --git a/android_webview/lib/main/webview_entry_point.cc b/android_webview/lib/main/webview_entry_point.cc index 8a4996f..506334c 100644 --- a/android_webview/lib/main/webview_entry_point.cc +++ b/android_webview/lib/main/webview_entry_point.cc @@ -8,6 +8,7 @@ #include "base/command_line.h" #include "content/public/app/android_library_loader_hooks.h" #include "content/public/app/content_main.h" +#include "content/public/browser/android/compositor.h" #include "content/public/common/content_switches.h" // This is called by the VM when the shared library is first loaded. @@ -26,6 +27,13 @@ JNI_EXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved) { CommandLine::ForCurrentProcess()->AppendSwitch( switches::kEnableWebViewSynchronousAPIs); + // TODO: The next two lines are temporarily required for the renderer + // initialization to not crash. + // See BUG 152904. + CommandLine::ForCurrentProcess()->AppendSwitch( + switches::kSingleProcess); + content::Compositor::Initialize(); + content::SetContentMainDelegate(new android_webview::AwMainDelegate()); return JNI_VERSION_1_4; diff --git a/content/browser/renderer_host/compositor_impl_android.cc b/content/browser/renderer_host/compositor_impl_android.cc index 9cb859f..5da1a65 100644 --- a/content/browser/renderer_host/compositor_impl_android.cc +++ b/content/browser/renderer_host/compositor_impl_android.cc @@ -7,6 +7,7 @@ #include <android/native_window_jni.h> #include "base/bind.h" +#include "base/command_line.h" #include "base/logging.h" #include "content/browser/gpu/browser_gpu_channel_host_factory.h" #include "content/browser/gpu/gpu_surface_tracker.h" @@ -14,6 +15,7 @@ #include "content/common/gpu/client/gpu_channel_host.h" #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h" #include "content/common/gpu/gpu_process_launch_causes.h" +#include "content/public/common/content_switches.h" #include "third_party/WebKit/Source/Platform/chromium/public/Platform.h" #include "third_party/WebKit/Source/Platform/chromium/public/WebCompositorSupport.h" #include "third_party/WebKit/Source/Platform/chromium/public/WebCompositorOutputSurface.h" @@ -76,6 +78,24 @@ Compositor* Compositor::Create() { // static void Compositor::Initialize() { g_initialized = true; + // Android WebView runs in single process, and depends on the renderer to + // perform WebKit::Platform initialization for the entire process. The + // renderer, however, does that lazily which in practice means it waits + // until the first page load request. + // The WebView-specific rendering code isn't ready yet so we only want to + // trick the rest of it into thinking the Compositor is initialized, which + // keeps us from crashing. + // See BUG 152904. + if (WebKit::Platform::current() == NULL) { + LOG(WARNING) << "CompositorImpl(Android)::Initialize(): WebKit::Platform " + << "is not initialized, COMPOSITOR IS NOT INITIALIZED " + << "(this is OK and expected if you're running Android" + << "WebView tests)."; + // We only ever want to run this hack in single process mode. + CHECK(CommandLine::ForCurrentProcess()->HasSwitch( + switches::kSingleProcess)); + return; + } WebKit::Platform::current()->compositorSupport()->initialize(NULL); } |