Delay the Wayland initialization in the WebProcess for WRT. 18/9018/2
authorJoone Hur <joone.hur@intel.com>
Fri, 30 Aug 2013 21:10:56 +0000 (14:10 -0700)
committerJoone Hur <joone.hur@intel.com>
Tue, 3 Sep 2013 18:11:26 +0000 (11:11 -0700)
Wayland initialization should be done in the UIProcess before the WebProcess
starts to do this, but in case of WRT, the WebProcess does this ahead of the UIProcess.
So, we have to initialize the PlatformSurfacePoolTizen in WebProcess::createWebPage,
not WebProcess::initialize because it is triggered by the createWebPage message sent
from the UIProcess, which delays the Wayland initialization in the WebProcess.

This patch fixes the bug below:
WebGL context creation hangs when called from a web app
https://bugs.tizen.org/jira/browse/TIVI-1602

Change-Id: I8c886e9693ec2b398db0700e8de48401999ced52

Source/WebCore/platform/graphics/surfaces/wayland/WaylandDisplay.cpp
Source/WebCore/platform/graphics/surfaces/wayland/WaylandDisplay.h
Source/WebKit2/Shared/WebPageCreationParameters.cpp
Source/WebKit2/Shared/WebPageCreationParameters.h
Source/WebKit2/UIProcess/WebPageProxy.cpp
Source/WebKit2/WebProcess/WebProcess.cpp

index 1fd9fb8..e85aae6 100644 (file)
@@ -38,7 +38,6 @@
 
 #include <wtf/text/CString.h>
 #include <wtf/text/StringBuilder.h>
-#include <wtf/text/WTFString.h>
 
 // os-compatibility
 extern "C" {
@@ -86,6 +85,7 @@ int osEpollCreateCloExec(void)
 namespace WebCore {
 
 WaylandDisplay* WaylandDisplay::m_instance = 0;
+String WaylandDisplay::m_socketString = "Wayland-";
 static int MAXEVENTS = 64;
 
 static const struct wl_registry_listener registrylistener = {
@@ -356,7 +356,6 @@ WaylandDisplay::WaylandDisplay()
 
 void WaylandDisplay::initialize(wl_display* display)
 {
-
     if (display) {
         m_eventDispatcher = WaylandPollThread::create();
         m_display = wl_display_create();
@@ -366,11 +365,8 @@ void WaylandDisplay::initialize(wl_display* display)
             return;
         }
 
-        String socketString("Wayland-");
-        socketString.append(String::format("%d", m_eventDispatcher->id()));
-        setenv("WAYLAND_NESTED_CLIENT", socketString.utf8().data(), 1);
-
-        if (wl_display_add_socket(m_display, socketString.utf8().data())) {
+        m_socketString.append(String::format("%d", m_eventDispatcher->id()));
+        if (wl_display_add_socket(m_display, m_socketString.utf8().data())) {
             LOG_ERROR("WaylandDisplay initialization failed:: Failed to Add socket.");
             terminate();
             return;
@@ -386,8 +382,7 @@ void WaylandDisplay::initialize(wl_display* display)
         m_eventDispatcher->start(m_display, display);
 
     } else {
-        const char* nestedSocket = getenv("WAYLAND_NESTED_CLIENT");
-        m_display = wl_display_connect(nestedSocket);
+        m_display = wl_display_connect(m_socketString.utf8().data());
 
         if (!m_display) {
             LOG_ERROR("WaylandDisplay initialization failed: Failed to make connection with Wayland.");
index 8aa6ee4..40c3ca3 100644 (file)
@@ -29,6 +29,8 @@
 #include "WaylandHelper.h"
 #include "WaylandSurface.h"
 
+#include <wtf/text/WTFString.h>
+
 namespace WebCore {
 class WaylandBuffer;
 
@@ -64,6 +66,9 @@ public:
     // callback handlers.
     static void syncCallback(void*, struct wl_callback*, uint32_t);
 
+    static void setSocketString(String socketString) { m_socketString = socketString; }
+    static String socketString() { return m_socketString; }
+
 protected:
     WaylandDisplay();
     virtual ~WaylandDisplay();
@@ -96,6 +101,8 @@ private:
     bool m_pendingEvents :1;
     friend class WaylandBuffer;
     friend class WaylandSurface;
+
+    static String m_socketString;
 };
 
 }
index 27d5543..f772abf 100644 (file)
@@ -51,6 +51,9 @@ void WebPageCreationParameters::encode(CoreIPC::ArgumentEncoder* encoder) const
     encoder->encode(pageLength);
     encoder->encode(gapBetweenPages);
     encoder->encode(userAgent);
+#if PLATFORM(WAYLAND)
+    encoder->encode(waylandSocketString);
+#endif
     encoder->encode(sessionState);
     encoder->encode(highestUsedBackForwardItemID);
     encoder->encode(canRunBeforeUnloadConfirmPanel);
@@ -107,6 +110,10 @@ bool WebPageCreationParameters::decode(CoreIPC::ArgumentDecoder* decoder, WebPag
         return false;
     if (!decoder->decode(parameters.userAgent))
         return false;
+#if PLATFORM(WAYLAND)
+    if (!decoder->decode(parameters.waylandSocketString))
+        return false;
+#endif
     if (!decoder->decode(parameters.sessionState))
         return false;
     if (!decoder->decode(parameters.highestUsedBackForwardItemID))
index ce85dce..2f03c8a 100644 (file)
@@ -93,6 +93,10 @@ struct WebPageCreationParameters {
 #if PLATFORM(WIN)
     HWND nativeWindow;
 #endif
+
+#if PLATFORM(WAYLAND)
+    String waylandSocketString;
+#endif
 };
 
 } // namespace WebKit
index 2a78b55..959cf9f 100755 (executable)
@@ -4199,6 +4199,10 @@ WebPageCreationParameters WebPageProxy::creationParameters() const
 #if PLATFORM(WIN)
     parameters.nativeWindow = m_pageClient->nativeWindow();
 #endif
+
+#if PLATFORM(WAYLAND)
+    parameters.waylandSocketString = WaylandDisplay::socketString();
+#endif
     return parameters;
 }
 
index 86f9711..8b33b8d 100644 (file)
 #include <WebCore/TizenExtensibleAPI.h>
 #endif
 
+#if PLATFORM(WAYLAND)
+#include "WaylandDisplay.h"
+#endif
+
 using namespace JSC;
 using namespace WebCore;
 
@@ -240,7 +244,9 @@ void WebProcess::initialize(CoreIPC::Connection::Identifier serverIdentifier, Ru
     connection()->setOnlySendMessagesAsDispatchWhenWaitingForSyncReplyWhenProcessingSuchAMessage(true);
 #endif
 
-#if ENABLE(TIZEN_WEBKIT2_TILED_AC_SHARED_PLATFORM_SURFACE)
+#if !PLATFORM(WAYLAND) && ENABLE(TIZEN_WEBKIT2_TILED_AC_SHARED_PLATFORM_SURFACE)
+    // In case of WRT, this causes WaylandDisplay initialization ahead of UIProcess.
+    // So, we have to initialize PlatformSurfacePoolTizen in WebProcess::createWebPage, not here.
     m_platformSurfacePool = adoptPtr(new PlatformSurfacePoolTizen());
 #endif
 
@@ -620,6 +626,10 @@ WebPage* WebProcess::webPage(uint64_t pageID) const
 
 void WebProcess::createWebPage(uint64_t pageID, const WebPageCreationParameters& parameters)
 {
+#if PLATFORM(WAYLAND)
+    WaylandDisplay::setSocketString(parameters.waylandSocketString);
+#endif
+
 #if ENABLE(TIZEN_WEBKIT2_TILED_AC_SHARED_PLATFORM_SURFACE)
     if (!m_platformSurfacePool)
         m_platformSurfacePool = adoptPtr(new PlatformSurfacePoolTizen());