<?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>243410</bug_id>
          
          <creation_ts>2022-08-01 10:27:27 -0700</creation_ts>
          <short_desc>REGRESSION(250037@main): wpt /service-workers/service-worker/registration-updateviacache.https.html has become flaky</short_desc>
          <delta_ts>2022-08-05 10:09:25 -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>Service Workers</component>
          <version>WebKit Nightly Build</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          <see_also>https://bugs.webkit.org/show_bug.cgi?id=239657</see_also>
    
    <see_also>https://bugs.webkit.org/show_bug.cgi?id=240074</see_also>
          <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>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Sam Sneddon [:gsnedders]">gsnedders</reporter>
          <assigned_to name="Chris Dumez">cdumez</assigned_to>
          <cc>cdumez</cc>
    
    <cc>rackler</cc>
    
    <cc>webkit-bug-importer</cc>
    
    <cc>youennf</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1888101</commentid>
    <comment_count>0</comment_count>
    <who name="Sam Sneddon [:gsnedders]">gsnedders</who>
    <bug_when>2022-08-01 10:27:27 -0700</bug_when>
    <thetext>See https://wpt.fyi/results/service-workers/service-worker/registration-updateviacache.https.html?label=master&amp;product=safari-15%5Bstable%5D&amp;product=safari%5Bexperimental%5D&amp;aligned&amp;view=subtest

A variety of subtests have regressed:

register-with-updateViaCache-all
register-with-updateViaCache-undefined-then-all
register-with-updateViaCache-imports-then-all
register-with-updateViaCache-none-then-all

https://github.com/WebKit/WebKit/blob/main/LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/registration-updateviacache.https-expected.txt makes it look like our test configuration passes there.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1888102</commentid>
    <comment_count>1</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2022-08-01 10:27:41 -0700</bug_when>
    <thetext>&lt;rdar://problem/97921749&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1888922</commentid>
    <comment_count>2</comment_count>
    <who name="Chris Dumez">cdumez</who>
    <bug_when>2022-08-04 11:53:05 -0700</bug_when>
    <thetext>The test is marked as flaky on iOS:
LayoutTests/platform/ios/TestExpectations:webkit.org/b/240074 imported/w3c/web-platform-tests/service-workers/service-worker/registration-updateviacache.https.html [ Pass Failure ]

But seems to be running on macOS.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1888925</commentid>
    <comment_count>3</comment_count>
    <who name="Chris Dumez">cdumez</who>
    <bug_when>2022-08-04 12:02:50 -0700</bug_when>
    <thetext>Similarly, in STP 150, I see all subtests passing expect the last one. Not sure why the wpt.fyi dashboard is saying differently.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1888928</commentid>
    <comment_count>4</comment_count>
    <who name="Chris Dumez">cdumez</who>
    <bug_when>2022-08-04 12:14:05 -0700</bug_when>
    <thetext>The flaky failure on iOS (https://bugs.webkit.org/show_bug.cgi?id=240074) looks a lot like the failure here. So I think the test is just flaky on iOS and macOS.

I guess I can try to reproduce the flakiness with iOS instead since our bots seem to indicate it is more prevalent on that platform.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1888936</commentid>
    <comment_count>5</comment_count>
    <who name="Chris Dumez">cdumez</who>
    <bug_when>2022-08-04 12:26:26 -0700</bug_when>
    <thetext>Previous attempt to fix it by Youenn (Bug 240074) was unsuccessful based on the flakiness dashboard and wpt.fyi results.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1888941</commentid>
    <comment_count>6</comment_count>
    <who name="Chris Dumez">cdumez</who>
    <bug_when>2022-08-04 13:01:13 -0700</bug_when>
    <thetext>I do see one weirdness in our code here:
```
    // If newestWorker is not null, newestWorker&apos;s script url equals job&apos;s script url with the exclude fragments
    // flag set, and script&apos;s source text is a byte-for-byte match with newestWorker&apos;s script resource&apos;s source
    // text, then:
    if (newestWorker &amp;&amp; equalIgnoringFragmentIdentifier(newestWorker-&gt;scriptURL(), job.scriptURL) &amp;&amp; newestWorker-&gt;type() == job.workerType &amp;&amp; result.script == newestWorker-&gt;script() &amp;&amp; doCertificatesMatch(result.certificateInfo, newestWorker-&gt;certificateInfo())) {
```

But the spec says at https://w3c.github.io/ServiceWorker/#start-register (step 5.2):
```
If newestWorker is not null, job’s script url equals newestWorker’s script url, job’s worker type equals newestWorker’s type, and job’s update via cache mode&apos;s value equals registration’s update via cache mode, then:

Invoke Resolve Job Promise with job and registration.
Invoke Finish Job with job and abort these steps.
```

It seems we are missing the &quot;update via cache mode&quot; check. I&apos;ll try to reproduce the flakiness locally and see if this fixes it.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1888953</commentid>
    <comment_count>7</comment_count>
    <who name="Chris Dumez">cdumez</who>
    <bug_when>2022-08-04 13:30:11 -0700</bug_when>
    <thetext>(In reply to Chris Dumez from comment #6)
&gt; I do see one weirdness in our code here:
&gt; ```
&gt;     // If newestWorker is not null, newestWorker&apos;s script url equals job&apos;s
&gt; script url with the exclude fragments
&gt;     // flag set, and script&apos;s source text is a byte-for-byte match with
&gt; newestWorker&apos;s script resource&apos;s source
&gt;     // text, then:
&gt;     if (newestWorker &amp;&amp;
&gt; equalIgnoringFragmentIdentifier(newestWorker-&gt;scriptURL(), job.scriptURL) &amp;&amp;
&gt; newestWorker-&gt;type() == job.workerType &amp;&amp; result.script ==
&gt; newestWorker-&gt;script() &amp;&amp; doCertificatesMatch(result.certificateInfo,
&gt; newestWorker-&gt;certificateInfo())) {
&gt; ```
&gt; 
&gt; But the spec says at https://w3c.github.io/ServiceWorker/#start-register
&gt; (step 5.2):
&gt; ```
&gt; If newestWorker is not null, job’s script url equals newestWorker’s script
&gt; url, job’s worker type equals newestWorker’s type, and job’s update via
&gt; cache mode&apos;s value equals registration’s update via cache mode, then:
&gt; 
&gt; Invoke Resolve Job Promise with job and registration.
&gt; Invoke Finish Job with job and abort these steps.
&gt; ```
&gt; 
&gt; It seems we are missing the &quot;update via cache mode&quot; check. I&apos;ll try to
&gt; reproduce the flakiness locally and see if this fixes it.

Actually, we do have the updateViaCache check in runRegisterJob() already:
```
        auto* newestWorker = registration-&gt;getNewestWorker();
        if (newestWorker &amp;&amp; equalIgnoringFragmentIdentifier(job.scriptURL, newestWorker-&gt;scriptURL()) &amp;&amp; job.workerType == newestWorker-&gt;type() &amp;&amp; job.registrationOptions.updateViaCache == registration-&gt;updateViaCache()) {
            RELEASE_LOG(ServiceWorker, &quot;%p - SWServerJobQueue::runRegisterJob: Found directly reusable registration %llu for job %s (DONE)&quot;, this, registration-&gt;identifier().toUInt64(), job.identifier().loggingString().utf8().data());
            m_server.resolveRegistrationJob(job, registration-&gt;data(), ShouldNotifyWhenResolved::No);
            finishCurrentJob();
            return;
        }
```</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1889003</commentid>
    <comment_count>8</comment_count>
    <who name="Chris Dumez">cdumez</who>
    <bug_when>2022-08-04 16:16:32 -0700</bug_when>
    <thetext>I can&apos;t reproduce the flakiness on either macOS or iOS so I am kind of stuck.
I have tried both via WebKitTestRunner and in Safari and did many iterations.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1889010</commentid>
    <comment_count>9</comment_count>
    <who name="Chris Dumez">cdumez</who>
    <bug_when>2022-08-04 16:48:39 -0700</bug_when>
    <thetext>(In reply to Chris Dumez from comment #8)
&gt; I can&apos;t reproduce the flakiness on either macOS or iOS so I am kind of stuck.
&gt; I have tried both via WebKitTestRunner and in Safari and did many iterations.

Ok, I think I have a flaky reproduction now when running the test in Safari using a local http server instead of wpt.fyi.

Since Youenn&apos;s original patch was suspecting the memory cache, I tried disabling the memory cache but it didn&apos;t fix it.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1889030</commentid>
    <comment_count>10</comment_count>
    <who name="Chris Dumez">cdumez</who>
    <bug_when>2022-08-04 18:31:11 -0700</bug_when>
    <thetext>(In reply to Chris Dumez from comment #9)
&gt; (In reply to Chris Dumez from comment #8)
&gt; &gt; I can&apos;t reproduce the flakiness on either macOS or iOS so I am kind of stuck.
&gt; &gt; I have tried both via WebKitTestRunner and in Safari and did many iterations.
&gt; 
&gt; Ok, I think I have a flaky reproduction now when running the test in Safari
&gt; using a local http server instead of wpt.fyi.
&gt; 
&gt; Since Youenn&apos;s original patch was suspecting the memory cache, I tried
&gt; disabling the memory cache but it didn&apos;t fix it.

Never mind, I must have tested it wrong earlier. Disabling the memory cache definitely fixes it so Youenn was likely right about the issue. However, it seems his fix was incomplete.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1889038</commentid>
    <comment_count>11</comment_count>
    <who name="Chris Dumez">cdumez</who>
    <bug_when>2022-08-04 19:20:07 -0700</bug_when>
    <thetext>Pull request: https://github.com/WebKit/WebKit/pull/3034</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1889055</commentid>
    <comment_count>12</comment_count>
    <who name="EWS">ews-feeder</who>
    <bug_when>2022-08-04 21:44:22 -0700</bug_when>
    <thetext>Committed 253140@main (3f019cf4b5d2): &lt;https://commits.webkit.org/253140@main&gt;

Reviewed commits have been landed. Closing PR #3034 and removing active labels.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1889135</commentid>
    <comment_count>13</comment_count>
    <who name="Karl Rackler">rackler</who>
    <bug_when>2022-08-05 09:42:51 -0700</bug_when>
    <thetext>(In reply to Chris Dumez from comment #10)
&gt; (In reply to Chris Dumez from comment #9)
&gt; &gt; (In reply to Chris Dumez from comment #8)
&gt; &gt; &gt; I can&apos;t reproduce the flakiness on either macOS or iOS so I am kind of stuck.
&gt; &gt; &gt; I have tried both via WebKitTestRunner and in Safari and did many iterations.
&gt; &gt; 
&gt; &gt; Ok, I think I have a flaky reproduction now when running the test in Safari
&gt; &gt; using a local http server instead of wpt.fyi.
&gt; &gt; 
&gt; &gt; Since Youenn&apos;s original patch was suspecting the memory cache, I tried
&gt; &gt; disabling the memory cache but it didn&apos;t fix it.
&gt; 
&gt; Never mind, I must have tested it wrong earlier. Disabling the memory cache
&gt; definitely fixes it so Youenn was likely right about the issue. However, it
&gt; seems his fix was incomplete.

imported/w3c/web-platform-tests/service-workers/service-worker/registration-updateviacache.https.html is consistently passing after landing 251742@main with the exception of a one-off on 8/3/2022, 5:10:36 PM at 253089@main for iOS.  

Here is the history with &apos;Filter expected results&apos; off: 
https://results.webkit.org/?suite=layout-tests&amp;test=imported%2Fw3c%2Fweb-platform-tests%2Fservice-workers%2Fservice-worker%2Fregistration-updateviacache.https.html&amp;platform=ios&amp;platform=mac&amp;limit=50000</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1889136</commentid>
    <comment_count>14</comment_count>
    <who name="Karl Rackler">rackler</who>
    <bug_when>2022-08-05 09:45:04 -0700</bug_when>
    <thetext>(In reply to Chris Dumez from comment #11)
&gt; Pull request: https://github.com/WebKit/WebKit/pull/3034

After landing 253140@main, Debug is consistently crashing.

History: 
https://results.webkit.org/?suite=layout-tests&amp;test=imported%2Fw3c%2Fweb-platform-tests%2Fservice-workers%2Fservice-worker%2Fregistration-updateviacache.https.html&amp;platform=ios&amp;platform=mac&amp;limit=50000</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1889140</commentid>
    <comment_count>15</comment_count>
    <who name="Chris Dumez">cdumez</who>
    <bug_when>2022-08-05 09:47:01 -0700</bug_when>
    <thetext>(In reply to Karl Rackler from comment #14)
&gt; (In reply to Chris Dumez from comment #11)
&gt; &gt; Pull request: https://github.com/WebKit/WebKit/pull/3034
&gt; 
&gt; After landing 253140@main, Debug is consistently crashing.
&gt; 
&gt; History: 
&gt; https://results.webkit.org/?suite=layout-tests&amp;test=imported%2Fw3c%2Fweb-
&gt; platform-tests%2Fservice-workers%2Fservice-worker%2Fregistration-
&gt; updateviacache.https.html&amp;platform=ios&amp;platform=mac&amp;limit=50000

ASSERTION FAILED: jobData.connectionIdentifier() == Process::identifier()

Looking now.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1889142</commentid>
    <comment_count>16</comment_count>
    <who name="Chris Dumez">cdumez</who>
    <bug_when>2022-08-05 09:49:56 -0700</bug_when>
    <thetext>(In reply to Chris Dumez from comment #15)
&gt; (In reply to Karl Rackler from comment #14)
&gt; &gt; (In reply to Chris Dumez from comment #11)
&gt; &gt; &gt; Pull request: https://github.com/WebKit/WebKit/pull/3034
&gt; &gt; 
&gt; &gt; After landing 253140@main, Debug is consistently crashing.
&gt; &gt; 
&gt; &gt; History: 
&gt; &gt; https://results.webkit.org/?suite=layout-tests&amp;test=imported%2Fw3c%2Fweb-
&gt; &gt; platform-tests%2Fservice-workers%2Fservice-worker%2Fregistration-
&gt; &gt; updateviacache.https.html&amp;platform=ios&amp;platform=mac&amp;limit=50000
&gt; 
&gt; ASSERTION FAILED: jobData.connectionIdentifier() == Process::identifier()
&gt; 
&gt; Looking now.

Looks like an outdated assertion now that we do the refresh loads in the network process unconditionally. I&apos;ll fix shortly.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1889148</commentid>
    <comment_count>17</comment_count>
    <who name="Chris Dumez">cdumez</who>
    <bug_when>2022-08-05 10:09:25 -0700</bug_when>
    <thetext>(In reply to Chris Dumez from comment #16)
&gt; (In reply to Chris Dumez from comment #15)
&gt; &gt; (In reply to Karl Rackler from comment #14)
&gt; &gt; &gt; (In reply to Chris Dumez from comment #11)
&gt; &gt; &gt; &gt; Pull request: https://github.com/WebKit/WebKit/pull/3034
&gt; &gt; &gt; 
&gt; &gt; &gt; After landing 253140@main, Debug is consistently crashing.
&gt; &gt; &gt; 
&gt; &gt; &gt; History: 
&gt; &gt; &gt; https://results.webkit.org/?suite=layout-tests&amp;test=imported%2Fw3c%2Fweb-
&gt; &gt; &gt; platform-tests%2Fservice-workers%2Fservice-worker%2Fregistration-
&gt; &gt; &gt; updateviacache.https.html&amp;platform=ios&amp;platform=mac&amp;limit=50000
&gt; &gt; 
&gt; &gt; ASSERTION FAILED: jobData.connectionIdentifier() == Process::identifier()
&gt; &gt; 
&gt; &gt; Looking now.
&gt; 
&gt; Looks like an outdated assertion now that we do the refresh loads in the
&gt; network process unconditionally. I&apos;ll fix shortly.

Follow-up fix in https://commits.webkit.org/253148@main.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>