<?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>269846</bug_id>
          
          <creation_ts>2024-02-21 06:36:36 -0800</creation_ts>
          <short_desc>getUserMedia camera stream lost on history pushState in iOS 17.4 Beta 4</short_desc>
          <delta_ts>2024-05-21 14:53:42 -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>WebRTC</component>
          <version>Safari 17</version>
          <rep_platform>iPhone / iPad</rep_platform>
          <op_sys>iOS 17</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc>https://github.com/pixelverse-llc/gum-camera-lost-after-pushstate</bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>InRadar, Regression</keywords>
          <priority>P1</priority>
          <bug_severity>Major</bug_severity>
          <target_milestone>---</target_milestone>
          
          <blocked>270318</blocked>
          <everconfirmed>1</everconfirmed>
          <reporter name="Alex Suzuki">alex</reporter>
          <assigned_to name="Andy Estes">aestes</assigned_to>
          <cc>adamhenson1979</cc>
    
    <cc>adrien.micol</cc>
    
    <cc>jhenderson2177</cc>
    
    <cc>webkit-bug-importer</cc>
    
    <cc>youennf</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>2015745</commentid>
    <comment_count>0</comment_count>
    <who name="Alex Suzuki">alex</who>
    <bug_when>2024-02-21 06:36:36 -0800</bug_when>
    <thetext>In iOS 17.4 Beta 4 (and Beta 3 also, did not verify with earlier versions), Safari loses access to the camera stream obtained from getUserMedia() on history.pushState().

As history.pushState() is used in web frameworks for client-side routing, this breaks a lot barcode scanning apps and other apps that rely on the camera stream to be present across navigations.

Minimum reproducible sample:
https://github.com/pixelverse-llc/gum-camera-lost-after-pushstate

1) Load reproducer page
2) Allow camera access, camera feed is displayed
3) Press &apos;Push state&apos; button =&gt; camera feed is lsot</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2015747</commentid>
    <comment_count>1</comment_count>
      <attachid>470000</attachid>
    <who name="Alex Suzuki">alex</who>
    <bug_when>2024-02-21 06:39:41 -0800</bug_when>
    <thetext>Created attachment 470000
Minimum reproducible sample</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2015759</commentid>
    <comment_count>2</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2024-02-21 08:13:53 -0800</bug_when>
    <thetext>&lt;rdar://problem/123381737&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2015760</commentid>
    <comment_count>3</comment_count>
    <who name="youenn fablet">youennf</who>
    <bug_when>2024-02-21 08:15:40 -0800</bug_when>
    <thetext>I can reproduce.
I wonder whether this is a regression in iOS 17.4.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2015762</commentid>
    <comment_count>4</comment_count>
    <who name="youenn fablet">youennf</who>
    <bug_when>2024-02-21 08:17:28 -0800</bug_when>
    <thetext>(In reply to youenn fablet from comment #3)
&gt; I can reproduce.
&gt; I wonder whether this is a regression in iOS 17.4.

Capture is muted and does not recover without a user gesture.
Capture should probably not be muted in that case.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2015777</commentid>
    <comment_count>5</comment_count>
    <who name="Alex Suzuki">alex</who>
    <bug_when>2024-02-21 09:20:46 -0800</bug_when>
    <thetext>Hi youenn, thank you for the quick response – much appreciated.
I have tested the same sample on iOS 17.3 and it does not exhibit this behavior.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2016024</commentid>
    <comment_count>6</comment_count>
    <who name="Alex Suzuki">alex</who>
    <bug_when>2024-02-22 02:28:42 -0800</bug_when>
    <thetext>Per WebKit bug priority guidelines I&apos;m changing this to P1 (regression from previously released WebKit version)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2016066</commentid>
    <comment_count>7</comment_count>
    <who name="Alex Suzuki">alex</who>
    <bug_when>2024-02-22 06:37:16 -0800</bug_when>
    <thetext>Additional information: this behaviour also occurs if the camera permission setting for the website is &quot;Allow&quot;, or the blanket setting for all websites is &quot;Allow&quot;, so not presumably not a permission issue.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2016072</commentid>
    <comment_count>8</comment_count>
    <who name="Alex Suzuki">alex</who>
    <bug_when>2024-02-22 07:08:15 -0800</bug_when>
    <thetext>@youenn fablet: what exactly do you mean by &quot;does not recover without a user gesture&quot;? Does it mean the user tapping the crossed-through camera icon in the address bar and selecting &quot;Start using camera&quot;? Or is there a programmatic way, triggered through a touch event, to unmute the track?

I extended the reproducer repo with two buttons that do the following:
1) try to unmute track by setting track.enabled = true (does not work)
2) re-acquire MediaStream by releasing old stream/track and obtaining new MediaStream by calling getUserMedia() again (this works, but cumbersome and unexpected)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2016096</commentid>
    <comment_count>9</comment_count>
    <who name="youenn fablet">youennf</who>
    <bug_when>2024-02-22 09:02:41 -0800</bug_when>
    <thetext>(In reply to Alex Suzuki from comment #8)
&gt; @youenn fablet: what exactly do you mean by &quot;does not recover without a user
&gt; gesture&quot;? Does it mean the user tapping the crossed-through camera icon in
&gt; the address bar and selecting &quot;Start using camera&quot;? Or is there a
&gt; programmatic way, triggered through a touch event, to unmute the track?

The former (user tapping the camera icon).
No programmatic way unfortunately.
We are actively working on fixing this.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2016183</commentid>
    <comment_count>10</comment_count>
    <who name="Andy Estes">aestes</who>
    <bug_when>2024-02-22 13:28:24 -0800</bug_when>
    <thetext>Pull request: https://github.com/WebKit/WebKit/pull/24971</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2016329</commentid>
    <comment_count>11</comment_count>
    <who name="Alex Suzuki">alex</who>
    <bug_when>2024-02-23 00:07:26 -0800</bug_when>
    <thetext>Thank you so much for the very fast response to this issue.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2016408</commentid>
    <comment_count>12</comment_count>
    <who name="EWS">ews-feeder</who>
    <bug_when>2024-02-23 09:54:31 -0800</bug_when>
    <thetext>Committed 275244@main (d97f5a09e4f1): &lt;https://commits.webkit.org/275244@main&gt;

Reviewed commits have been landed. Closing PR #24971 and removing active labels.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2017410</commentid>
    <comment_count>13</comment_count>
    <who name="Alex Suzuki">alex</who>
    <bug_when>2024-02-27 23:46:48 -0800</bug_when>
    <thetext>I just checked with the iOS 17.4 Public Beta (build 21E217), and the issue still exists. Does this mean that this fix will not make it into iOS 17.4?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2018818</commentid>
    <comment_count>14</comment_count>
    <who name="Alex Suzuki">alex</who>
    <bug_when>2024-03-05 10:30:43 -0800</bug_when>
    <thetext>Checked with the now release iOS 17.4, unfortunately this is still present and can be easily reproduced with the linked sample.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2022010</commentid>
    <comment_count>15</comment_count>
    <who name="Adam">adamhenson1979</who>
    <bug_when>2024-03-18 19:34:43 -0700</bug_when>
    <thetext>Hello - I discovered this issue in iOS 17.4 and also opened a ticket here: https://bugs.webkit.org/show_bug.cgi?id=271127. Sorry for the duplicate as I didn&apos;t find this existing bug report. I also added a minimal reproducible sample in the ticket I opened if it helps.

I couldn&apos;t tell if the PR to fix this didn&apos;t make it with the release even though the bug did or if the PR didn&apos;t actually fix the issue.

Is there any idea when this issue will be fixed?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2022092</commentid>
    <comment_count>16</comment_count>
    <who name="youenn fablet">youennf</who>
    <bug_when>2024-03-19 03:28:21 -0700</bug_when>
    <thetext>*** Bug 271127 has been marked as a duplicate of this bug. ***</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2022093</commentid>
    <comment_count>17</comment_count>
    <who name="youenn fablet">youennf</who>
    <bug_when>2024-03-19 03:29:24 -0700</bug_when>
    <thetext>Bug is fixed in WebKit ToT but I do not think a fix was released in any iOS build yet (stable or beta).

I&apos;ll try to comment when this gets out for you guys to validate it.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2022105</commentid>
    <comment_count>18</comment_count>
    <who name="Alex Suzuki">alex</who>
    <bug_when>2024-03-19 04:09:36 -0700</bug_when>
    <thetext>The issue is definitely still present in iOS 17.4. I hope it makes it into 17.4.1.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2022127</commentid>
    <comment_count>19</comment_count>
    <who name="Adam">adamhenson1979</who>
    <bug_when>2024-03-19 06:45:53 -0700</bug_when>
    <thetext>Thanks @youenn - I appreciate the help. I understand this is a P1 already, but if it helps escalate at all, here are some notes on the level of impact I&apos;m experiencing.

Because this is a new regression, introduced in Safari iOS 17.4, I would expect many more reports due to the variety of use cases that could involve a webcam stream and client side navigation. I think the reason there may not be more reports yet is because the issue is difficult to pinpoint in an existing app. Once it is pinpointed however, it is simple to reproduce consistently per Alex&apos;s minimum reproducible sample and mine. In these cases, the webcam stream goes completely black, blocking main functionality (like scanning barcodes, taking pictures, etc). I would expect a lot of these cases to involve a highly negative business impact. Speaking for myself, as a software engineer, I found this bug difficult to pinpoint as it was hidden within application code. I&apos;m now faced with the challenge of (temporarily) replacing client side navigation with browser storage functionality, which is a large and delicate task. My workaround is not ideal though as it will degrade the product. And until I&apos;m able to reliably rollout my workaround, large volumes of users are having a poor experience on our website.

Anyways, I don&apos;t want to add too much noise, but I hope this gets escalated accordingly and hope that my above experience is useful. I&apos;ll stay tuned.

Thanks again for the help!</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2022882</commentid>
    <comment_count>20</comment_count>
    <who name="Alex Suzuki">alex</who>
    <bug_when>2024-03-21 14:24:29 -0700</bug_when>
    <thetext>Issue still occurs in iOS 17.4.1</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2024180</commentid>
    <comment_count>21</comment_count>
    <who name="youenn fablet">youennf</who>
    <bug_when>2024-03-27 08:21:01 -0700</bug_when>
    <thetext>*** Bug 271637 has been marked as a duplicate of this bug. ***</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2025626</commentid>
    <comment_count>22</comment_count>
    <who name="Alex Suzuki">alex</who>
    <bug_when>2024-04-03 00:22:10 -0700</bug_when>
    <thetext>Issue seems to be fixed in iOS 17.5 Developer Beta 1</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2025660</commentid>
    <comment_count>23</comment_count>
    <who name="youenn fablet">youennf</who>
    <bug_when>2024-04-03 05:41:38 -0700</bug_when>
    <thetext>(In reply to Alex Suzuki from comment #22)
&gt; Issue seems to be fixed in iOS 17.5 Developer Beta 1</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2029766</commentid>
    <comment_count>24</comment_count>
    <who name="Ahmad Saleem">ahmad.saleem792</who>
    <bug_when>2024-04-19 02:58:59 -0700</bug_when>
    <thetext>*** Bug 272704 has been marked as a duplicate of this bug. ***</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2035349</commentid>
    <comment_count>25</comment_count>
    <who name="Adam">adamhenson1979</who>
    <bug_when>2024-05-14 13:14:42 -0700</bug_when>
    <thetext>I&apos;m seeing this issue now in Chrome for iOS version 124.0.6367.111 via this reproduction link: https://get-user-media-sage.vercel.app/

Description of the repro link: https://github.com/adamhenson/get-user-media

Is it known that this exists not just in Safari for iOS but also Chrome for iOS?

Will the PR from this comment (https://bugs.webkit.org/show_bug.cgi?id=269846#c12)in iOS 17.5 stable for all Webkit browsers (not just Safari for iOS)?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2035366</commentid>
    <comment_count>26</comment_count>
    <who name="Alexey Proskuryakov">ap</who>
    <bug_when>2024-05-14 14:24:26 -0700</bug_when>
    <thetext>This fix was in WebKit code, and would apply to all clients. There may be additional issues though.

If you are still seeing similar issues in iOS 17.5, including in Chrome, please file a new bug with an example, steps to reproduce, and anything you know about when this last worked. Ideally, please have everything in the bug report, clicking through to other bugs or GitHub takes time and increases confusion.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2036827</commentid>
    <comment_count>27</comment_count>
    <who name="Adam">adamhenson1979</who>
    <bug_when>2024-05-21 14:53:42 -0700</bug_when>
    <thetext>I just wanted to follow up here to comment that I tested and confirmed fix in 17.5.0 (tested on 17.5.1 using my repro from https://bugs.webkit.org/show_bug.cgi?id=271127).

Thank you all for the swift help / turnaround and thank you Andy Estes for the fix.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>470000</attachid>
            <date>2024-02-21 06:39:41 -0800</date>
            <delta_ts>2024-02-21 06:39:41 -0800</delta_ts>
            <desc>Minimum reproducible sample</desc>
            <filename>index.html</filename>
            <type>text/html</type>
            <size>1587</size>
            <attacher name="Alex Suzuki">alex</attacher>
            
              <data encoding="base64">PCFET0NUWVBFIGh0bWw+CjxodG1sIGxhbmc9ImVuIj4KPGhlYWQ+CiAgICA8bWV0YSBjaGFyc2V0
PSJVVEYtOCI+CiAgICA8bWV0YSBuYW1lPSJ2aWV3cG9ydCIgY29udGVudD0id2lkdGg9ZGV2aWNl
LXdpZHRoLCBpbml0aWFsLXNjYWxlPTEuMCwgbWF4aW11bS1zY2FsZT0xLjAsIHVzZXItc2NhbGFi
bGU9bm8iPgogICAgPHRpdGxlPmlPUyAxNy40IEJldGEgNCBsb3NlcyBjYW1lcmEgYWNjZXNzIG9u
IHB1c2hTdGF0ZTwvdGl0bGU+CiAgICA8c3R5bGU+CgogICAgICAgICNjYW1lcmFfc3RyZWFtIHsK
ICAgICAgICAgICAgd2lkdGg6IDEwMCU7CiAgICAgICAgICAgIGhlaWdodDogMzAwcHg7CiAgICAg
ICAgICAgIG9iamVjdC1maXQ6IGNvdmVyOwogICAgICAgIH0KICA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WxlbWVudEJ5SWQoJ3B1c2hT
dGF0ZUJ1dHRvbicpLm9uY2xpY2sgPSAoKSA9PiB7CiAgICAgICAgc3RlcCsrOwogICAgICAgIGhp
c3RvcnkucHVzaFN0YXRlKHsgc3RlcCB9LCAnJywgJy9zdGVwJyArIHN0ZXAudG9TdHJpbmcoKSk7
CiAgICAgICAgZG9jdW1lbnQuZ2V0RWxlbWVudEJ5SWQoJ2JhY2tCdXR0b24nKS5kaXNhYmxlZCA9
IGZhbHNlOwogICAgfTsKICAgIGRvY3VtZW50LmdldEVsZW1lbnRCeUlkKCdiYWNrQnV0dG9uJyku
b25jbGljayA9ICgpID0+IHsKICAgICAgICBzdGVwLS07CiAgICAgICAgaGlzdG9yeS5iYWNrKCk7
CiAgICAgICAgZG9jdW1lbnQuZ2V0RWxlbWVudEJ5SWQoJ2JhY2tCdXR0b24nKS5kaXNhYmxlZCA9
IChzdGVwID09PSAwKTsKICAgIH0KPC9zY3JpcHQ+Cgo8L2JvZHk+CjwvaHRtbD4K
</data>

          </attachment>
      

    </bug>

</bugzilla>