Title: [266442] branches/safari-610-branch/Source/WTF
Revision
266442
Author
[email protected]
Date
2020-09-01 18:31:45 -0700 (Tue, 01 Sep 2020)

Log Message

Cherry-pick r266145. rdar://problem/68179384

    [Win] Assert failure under RunLoop::RunLoop
    https://bugs.webkit.org/show_bug.cgi?id=215812

    Reviewed by Brent Fulgham.

    The assert 'ASSERT(::IsWindow(m_runLoopMessageWindow))' under RunLoop::RunLoop will fail if the JSC API JSGlobalContextCreate*()
    is being called by a client before WTF::initializeMainThread() has been called. The assertion fails because the method
    RunLoop::registerRunLoopMessageWindowClass() has not been called yet, since it is only called when initializing the main thread.
    This patch addresses this issue by making sure the window class has been registered before being referenced in RunLoop::RunLoopl
    The method call is also removed from the main thread initialization, since the window class is only used in RunLoop::RunLoop,
    making it sufficient to only be registered there. Also change the debug assert to a release assert, so we can catch similar
    issues in release builds.

    * wtf/win/MainThreadWin.cpp:
    (WTF::initializeMainThreadPlatform):
    * wtf/win/RunLoopWin.cpp:
    (WTF::RunLoop::registerRunLoopMessageWindowClass):
    (WTF::RunLoop::RunLoop):

    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266145 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Modified Paths

Diff

Modified: branches/safari-610-branch/Source/WTF/ChangeLog (266441 => 266442)


--- branches/safari-610-branch/Source/WTF/ChangeLog	2020-09-02 01:30:42 UTC (rev 266441)
+++ branches/safari-610-branch/Source/WTF/ChangeLog	2020-09-02 01:31:45 UTC (rev 266442)
@@ -1,3 +1,50 @@
+2020-09-01  Alan Coon  <[email protected]>
+
+        Cherry-pick r266145. rdar://problem/68179384
+
+    [Win] Assert failure under RunLoop::RunLoop
+    https://bugs.webkit.org/show_bug.cgi?id=215812
+    
+    Reviewed by Brent Fulgham.
+    
+    The assert 'ASSERT(::IsWindow(m_runLoopMessageWindow))' under RunLoop::RunLoop will fail if the JSC API JSGlobalContextCreate*()
+    is being called by a client before WTF::initializeMainThread() has been called. The assertion fails because the method
+    RunLoop::registerRunLoopMessageWindowClass() has not been called yet, since it is only called when initializing the main thread.
+    This patch addresses this issue by making sure the window class has been registered before being referenced in RunLoop::RunLoopl
+    The method call is also removed from the main thread initialization, since the window class is only used in RunLoop::RunLoop,
+    making it sufficient to only be registered there. Also change the debug assert to a release assert, so we can catch similar
+    issues in release builds.
+    
+    * wtf/win/MainThreadWin.cpp:
+    (WTF::initializeMainThreadPlatform):
+    * wtf/win/RunLoopWin.cpp:
+    (WTF::RunLoop::registerRunLoopMessageWindowClass):
+    (WTF::RunLoop::RunLoop):
+    
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266145 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2020-08-25  Per Arne Vollan  <[email protected]>
+
+            [Win] Assert failure under RunLoop::RunLoop
+            https://bugs.webkit.org/show_bug.cgi?id=215812
+
+            Reviewed by Brent Fulgham.
+
+            The assert 'ASSERT(::IsWindow(m_runLoopMessageWindow))' under RunLoop::RunLoop will fail if the JSC API JSGlobalContextCreate*()
+            is being called by a client before WTF::initializeMainThread() has been called. The assertion fails because the method
+            RunLoop::registerRunLoopMessageWindowClass() has not been called yet, since it is only called when initializing the main thread.
+            This patch addresses this issue by making sure the window class has been registered before being referenced in RunLoop::RunLoopl
+            The method call is also removed from the main thread initialization, since the window class is only used in RunLoop::RunLoop,
+            making it sufficient to only be registered there. Also change the debug assert to a release assert, so we can catch similar
+            issues in release builds.
+
+            * wtf/win/MainThreadWin.cpp:
+            (WTF::initializeMainThreadPlatform):
+            * wtf/win/RunLoopWin.cpp:
+            (WTF::RunLoop::registerRunLoopMessageWindowClass):
+            (WTF::RunLoop::RunLoop):
+
 2020-08-26  Alan Coon  <[email protected]>
 
         Cherry-pick r266087. rdar://problem/67836301

Modified: branches/safari-610-branch/Source/WTF/wtf/win/MainThreadWin.cpp (266441 => 266442)


--- branches/safari-610-branch/Source/WTF/wtf/win/MainThreadWin.cpp	2020-09-02 01:30:42 UTC (rev 266441)
+++ branches/safari-610-branch/Source/WTF/wtf/win/MainThreadWin.cpp	2020-09-02 01:31:45 UTC (rev 266442)
@@ -43,7 +43,6 @@
 {
     mainThread = Thread::currentID();
     Thread::initializeCurrentThreadInternal("Main Thread");
-    RunLoop::registerRunLoopMessageWindowClass();
 }
 
 bool isMainThread()

Modified: branches/safari-610-branch/Source/WTF/wtf/win/RunLoopWin.cpp (266441 => 266442)


--- branches/safari-610-branch/Source/WTF/wtf/win/RunLoopWin.cpp	2020-09-02 01:30:42 UTC (rev 266441)
+++ branches/safari-610-branch/Source/WTF/wtf/win/RunLoopWin.cpp	2020-09-02 01:31:45 UTC (rev 266442)
@@ -99,19 +99,23 @@
 
 void RunLoop::registerRunLoopMessageWindowClass()
 {
-    WNDCLASS windowClass = { };
-    windowClass.lpfnWndProc     = RunLoop::RunLoopWndProc;
-    windowClass.cbWndExtra      = sizeof(RunLoop*);
-    windowClass.lpszClassName   = kRunLoopMessageWindowClassName;
-    bool result = ::RegisterClass(&windowClass);
-    RELEASE_ASSERT(result);
+    static std::once_flag onceKey;
+    std::call_once(onceKey, [&] {
+        WNDCLASS windowClass = { };
+        windowClass.lpfnWndProc     = RunLoop::RunLoopWndProc;
+        windowClass.cbWndExtra      = sizeof(RunLoop*);
+        windowClass.lpszClassName   = kRunLoopMessageWindowClassName;
+        bool result = ::RegisterClass(&windowClass);
+        RELEASE_ASSERT(result);
+    });
 }
 
 RunLoop::RunLoop()
 {
+    registerRunLoopMessageWindowClass();
     m_runLoopMessageWindow = ::CreateWindow(kRunLoopMessageWindowClassName, nullptr, 0,
         CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, HWND_MESSAGE, nullptr, nullptr, this);
-    ASSERT(::IsWindow(m_runLoopMessageWindow));
+    RELEASE_ASSERT(::IsWindow(m_runLoopMessageWindow));
 }
 
 RunLoop::~RunLoop()
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to