<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>262681</bug_id>
          
          <creation_ts>2023-10-04 23:34:06 -0700</creation_ts>
          <short_desc>REGRESSION(267014@main): &quot;ASSERTION FAILED: Unhandled message GPUConnectionToWebProcess_ReleaseGraphicsContextGL to 0&quot; for fast/canvas/webgl/canvas-webgl-page-cache.html</short_desc>
          <delta_ts>2023-10-05 02:00:12 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>WebGL</component>
          <version>WebKit Nightly Build</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>DUPLICATE</resolution>
          <dup_id>262401</dup_id>
          <see_also>https://bugs.webkit.org/show_bug.cgi?id=262401</see_also>
    
    <see_also>https://bugs.webkit.org/show_bug.cgi?id=259552</see_also>
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Fujii Hironori">fujii</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>dino</cc>
    
    <cc>kbr</cc>
    
    <cc>kkinnunen</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1982761</commentid>
    <comment_count>0</comment_count>
    <who name="Fujii Hironori">fujii</who>
    <bug_when>2023-10-04 23:34:06 -0700</bug_when>
    <thetext>Windows port is observing an assertion failure.

&gt; python.exe ./Tools/Scripts/run-webkit-tests --debug fast/canvas/webgl/canvas-webgl-page-cache.html

It is passing but crashing WebKitGPUProcess.exe.

ASSERTION FAILED: Unhandled message GPUConnectionToWebProcess_ReleaseGraphicsContextGL to 0
assertionFailureDueToUnreachableCode
C:\home\webkit\gc\WebKitBuild\Debug\WebKit\DerivedSources\GPUConnectionToWebProcessMessageReceiver.cpp(136) : didReceiveMessage
1   00007FFDE6331C19 WTFCrash
2   00007FFDDB9DA22F WebKit::GPUConnectionToWebProcess::didReceiveMessage
3   00007FFDDC6AB29A IPC::Connection::dispatchMessage
4   00007FFDDC6AB50E IPC::Connection::dispatchMessage
5   00007FFDDC6B148E IPC::Connection::SyncMessageState::ConnectionAndIncomingMessage::dispatch
6   00007FFDDC6A5FF2 IPC::Connection::SyncMessageState::dispatchMessagesAndResetDidScheduleDispatchMessagesForConnection
7   00007FFDDC6AB886 IPC::Connection::dispatchSyncStateMessages
8   00007FFDDC6AD41B IPC::Connection::SyncMessageState::processIncomingMessage::&lt;lambda_3&gt;::operator()
9   00007FFDDC6AD3B7 WTF::Detail::CallableWrapper&lt;`lambda at C:\home\webkit\gc\Source\WebKit\Platform\IPC\Connection.cpp:224:31&apos;,void&gt;::call
10  00007FFDE63481A4 WTF::Function&lt;void ()&gt;::operator()
11  00007FFDE63CAF2A WTF::RunLoop::performWork
12  00007FFDE649F220 WTF::RunLoop::wndProc
13  00007FFDE649F157 WTF::RunLoop::RunLoopWndProc
14  00007FFE3DEFE858 CallWindowProcW
15  00007FFE3DEFE299 DispatchMessageW
16  00007FFDE649F3ED WTF::RunLoop::run
17  00007FFDDB835413 WebKit::AuxiliaryProcessMainBase&lt;WebKit::GPUProcess,0&gt;::run
18  00007FFDDB8352C7 WebKit::AuxiliaryProcessMain&lt;WebKit::GPUProcessMainWin&gt;
19  00007FFDDB8351A3 WebKit::GPUProcessMain
20  00007FF63617124C main
21  00007FF6361718BC __scrt_common_main_seh
22  00007FFE3CBC7344 BaseThreadInitThunk
23  00007FFE3E7E26B1 RtlUserThreadStart
Exception thrown at 0x00007FFDE6331C1E (WTF.dll) in WebKitGPUProcess.exe: 0xC0000005: Access violation writing location 0x00000000BBADBEEF.

I don&apos;t know the regresion point. I&apos;m testing with 268897@main.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1982764</commentid>
    <comment_count>1</comment_count>
    <who name="Fujii Hironori">fujii</who>
    <bug_when>2023-10-04 23:57:49 -0700</bug_when>
    <thetext>the assertion was added by 267014@main (bug#259552)?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1982773</commentid>
    <comment_count>2</comment_count>
    <who name="Fujii Hironori">fujii</who>
    <bug_when>2023-10-05 00:44:17 -0700</bug_when>
    <thetext>There is a race condition.
Web process sends Messages::GPUConnectionToWebProcess::ReleaseGraphicsContextGL when GraphicsContextGL is destroyed.
UI process sends Messages::GPUProcess::UpdatePreferencesForWebProcess to disable WebGL flag when all WebPageProxy is closed.
If UpdatePreferencesForWebProcess is dispatch before ReleaseGraphicsContextGL, the assertion fails.

Here is the callstack of updatePreferencesForWebProcess of UI process:

&gt; WebKit2.dll!WebKit::GPUProcessProxy::updatePreferencesForWebProcess(WebKit::WebProcessProxy &amp; webProcessProxy, const WebKit::GPUProcessPreferencesForWebProcess &amp; preferences) Line 453	C++
&gt; WebKit2.dll!WebKit::WebProcessProxy::updatePreferencesForGPUProcess() Line 2018	C++
&gt; WebKit2.dll!WebKit::WebProcessProxy::removeWebPage(WebKit::WebPageProxy &amp; webPage, WebKit::WebProcessProxy::EndsUsingDataStore endsUsingDataStore) Line 832	C++
&gt; WebKit2.dll!WebKit::WebPageProxy::close() Line 1455	C++
&gt; WebKit2.dll!WebKit::WebView::close() Line 781	C++
&gt; WebKit2.dll!WebKit::WebView::wndProc(HWND__ * hWnd, unsigned int message, unsigned __int64 wParam, __int64 lParam) Line 114	C++
&gt; WebKit2.dll!WebKit::WebView::WebViewWndProc(HWND__ * hWnd, unsigned int message, unsigned __int64 wParam, __int64 lParam) Line 89	C++
&gt; [External Code]	
&gt; WebKitTestRunner.exe!WTR::PlatformWebView::~PlatformWebView() Line 97	C++
&gt; [External Code]	
&gt; WebKitTestRunner.exe!WTR::TestController::~TestController() Line 205	C++
&gt; WebKitTestRunner.exe!main(int argc, const char * * argv) Line 34	C++
&gt; [External Code]	

Adding Sleep works around the crash.

diff --git a/Source/WebKit/UIProcess/GPU/GPUProcessProxy.cpp b/Source/WebKit/UIProcess/GPU/GPUProcessProxy.cpp
index 82e675719ae0..4e044bb593f5 100644
--- a/Source/WebKit/UIProcess/GPU/GPUProcessProxy.cpp
+++ b/Source/WebKit/UIProcess/GPU/GPUProcessProxy.cpp
@@ -450,6 +450,7 @@ std::optional&lt;bool&gt; GPUProcessProxy::s_hasVP9ExtensionSupport;
 
 void GPUProcessProxy::updatePreferencesForWebProcess(WebProcessProxy&amp; webProcessProxy, const GPUProcessPreferencesForWebProcess&amp; preferences)
 {
+    Sleep(1000);
     send(Messages::GPUProcess::UpdatePreferencesForWebProcess(webProcessProxy.coreProcessIdentifier(), preferences), 0);
 }</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1982796</commentid>
    <comment_count>3</comment_count>
    <who name="Kimmo Kinnunen">kkinnunen</who>
    <bug_when>2023-10-05 02:00:12 -0700</bug_when>
    <thetext>Thanks for the investigation. Let&apos;s continue fixing in the earlier bug.

*** This bug has been marked as a duplicate of bug 262401 ***</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>