<?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>298501</bug_id>
          
          <creation_ts>2025-09-06 10:26:31 -0700</creation_ts>
          <short_desc>ASSERT fires when calling CanvasRenderingContext2D::reset() after beginning a layer with a filter</short_desc>
          <delta_ts>2025-09-18 15:46:02 -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>Canvas</component>
          <version>WebKit Nightly Build</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          <blocked>243816</blocked>
    
    <blocked>267566</blocked>
          <everconfirmed>1</everconfirmed>
          <reporter name="Said Abou-Hallawa">sabouhallawa</reporter>
          <assigned_to name="Said Abou-Hallawa">sabouhallawa</assigned_to>
          <cc>sabouhallawa</cc>
    
    <cc>webkit-bug-importer</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>2141446</commentid>
    <comment_count>0</comment_count>
    <who name="Said Abou-Hallawa">sabouhallawa</who>
    <bug_when>2025-09-06 10:26:31 -0700</bug_when>
    <thetext>1. Enable &quot;Canvas Filters&quot; and &quot;Canvas Layers&quot; from Experimental Features
2. Open the attached test case in a debug mini-browser

Result: This ASSERT fires:

ASSERTION FAILED: purpose == m_state.purpose()
/Volumes/Data/WebKit/OpenSource/Source/WebCore/platform/graphics/GraphicsContext.cpp(82) : virtual void WebCore::GraphicsContext::restore(GraphicsContextState::Purpose)
1   0x306f328b4 WebCore::GraphicsContext::restore(WebCore::GraphicsContextState::Purpose)
2   0x30721beec WebCore::DisplayList::Recorder::updateStateForEndTransparencyLayer()
3   0x11905d538 WebKit::RemoteGraphicsContextProxy::endTransparencyLayer()
4   0x30707b418 WebCore::TransparencyLayerContextSwitcher::endDrawSourceImage(WebCore::GraphicsContext&amp;, WebCore::DestinationColorSpace const&amp;)
5   0x305e2b078 WebCore::CanvasLayerContextSwitcher::~CanvasLayerContextSwitcher()
6   0x305e2b0f8 WebCore::CanvasLayerContextSwitcher::~CanvasLayerContextSwitcher()
7   0x305e2a4d8 WTF::RefCounted&lt;WebCore::CanvasLayerContextSwitcher&gt;::deref() const
8   0x305e2a45c WTF::DefaultRefDerefTraits&lt;WebCore::CanvasLayerContextSwitcher&gt;::derefIfNotNull(WebCore::CanvasLayerContextSwitcher*)
9   0x305e2a424 WTF::RefPtr&lt;WebCore::CanvasLayerContextSwitcher, WTF::RawPtrTraits&lt;WebCore::CanvasLayerContextSwitcher&gt;, WTF::DefaultRefDerefTraits&lt;WebCore::CanvasLayerContextSwitcher&gt;&gt;::~RefPtr()
10  0x305e203e4 WTF::RefPtr&lt;WebCore::CanvasLayerContextSwitcher, WTF::RawPtrTraits&lt;WebCore::CanvasLayerContextSwitcher&gt;, WTF::DefaultRefDerefTraits&lt;WebCore::CanvasLayerContextSwitcher&gt;&gt;::~RefPtr()
11  0x305e4acc0 WebCore::CanvasRenderingContext2DBase::State::~State()
12  0x305e3407c WebCore::CanvasRenderingContext2DBase::State::~State()
13  0x305e59fd4 WTF::VectorDestructor&lt;true, WebCore::CanvasRenderingContext2DBase::State&gt;::destruct(WebCore::CanvasRenderingContext2DBase::State*, WebCore::CanvasRenderingContext2DBase::State*)
14  0x305e59f30 WTF::VectorTypeOperations&lt;WebCore::CanvasRenderingContext2DBase::State&gt;::destruct(WebCore::CanvasRenderingContext2DBase::State*, WebCore::CanvasRenderingContext2DBase::State*)
15  0x305e33de4 WTF::Vector&lt;WebCore::CanvasRenderingContext2DBase::State, 1ul, WTF::CrashOnOverflow, 16ul, WTF::FastMalloc&gt;::resize(unsigned long)
16  0x305e33c50 WebCore::CanvasRenderingContext2DBase::reset()
17  0x300f38a20 WebCore::jsCanvasRenderingContext2DPrototypeFunction_resetBody(JSC::JSGlobalObject*, JSC::CallFrame*, WebCore::JSCanvasRenderingContext2D*)::&apos;lambda&apos;()::operator()() const</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2141456</commentid>
    <comment_count>1</comment_count>
      <attachid>476664</attachid>
    <who name="Said Abou-Hallawa">sabouhallawa</who>
    <bug_when>2025-09-06 11:09:00 -0700</bug_when>
    <thetext>Created attachment 476664
test case</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2141457</commentid>
    <comment_count>2</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2025-09-06 11:09:34 -0700</bug_when>
    <thetext>&lt;rdar://problem/160017871&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2141458</commentid>
    <comment_count>3</comment_count>
    <who name="Said Abou-Hallawa">sabouhallawa</who>
    <bug_when>2025-09-06 11:38:32 -0700</bug_when>
    <thetext>Pull request: https://github.com/WebKit/WebKit/pull/50414</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2141634</commentid>
    <comment_count>4</comment_count>
    <who name="EWS">ews-feeder</who>
    <bug_when>2025-09-08 09:56:05 -0700</bug_when>
    <thetext>Committed 299695@main (ec19ea6f1987): &lt;https://commits.webkit.org/299695@main&gt;

Reviewed commits have been landed. Closing PR #50414 and removing active labels.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>476664</attachid>
            <date>2025-09-06 11:09:00 -0700</date>
            <delta_ts>2025-09-06 11:09:00 -0700</delta_ts>
            <desc>test case</desc>
            <filename>canvas-reset-layer-filter-no-end.html</filename>
            <type>text/html</type>
            <size>482</size>
            <attacher name="Said Abou-Hallawa">sabouhallawa</attacher>
            
              <data encoding="base64">PGJvZHk+CiAgICA8aDI+VGhpcyB0ZXN0IGVuc3VyZXMgdGhhdCBjYWxsaW5nIHJlc2V0KCkgYWZ0
ZXIgc3RhcnRpbmcgYSBsYXllciB3aXRoIGEgZmlsdGVyIGRvZXMgbm90IGNyYXNoLjwvaDI+CiAg
ICA8Y2FudmFzIGlkPSJjYW52YXMiIHdpZHRoPSIxMDAiIGhlaWdodD0iNTAiPjwvY2FudmFzPgog
ICAgPHNjcmlwdD4KICAgICAgICBpZiAod2luZG93LnRlc3RSdW5uZXIpCiAgICAgICAgICAgIHRl
c3RSdW5uZXIuZHVtcEFzVGV4dCgpOwoKICAgICAgICBjb25zdCBjYW52YXMgPSBkb2N1bWVudC5n
ZXRFbGVtZW50QnlJZCgiY2FudmFzIik7CiAgICAgICAgY29uc3QgY3R4ID0gY2FudmFzLmdldENv
bnRleHQoJzJkJyk7CgogICAgICAgIGN0eC5maWx0ZXIgPSAnZHJvcC1zaGFkb3coMTBweCAxMHB4
IDBweCBncmVlbiknOwogICAgICAgIGN0eC5iZWdpbkxheWVyKCk7CiAgICAgICAgY3R4LnJlc2V0
KCk7CiAgICA8L3NjcmlwdD4KPC9ib2R5Pgo=
</data>

          </attachment>
      

    </bug>

</bugzilla>