history.replaceState() causes user media video to became black on iOS 17

I have a case, when I need to update a browser’s URL while a user is streaming video from an iPhone. I update the URL like this.
window.history.replaceState(null, "", browserUrl);

On iOS 17 it causes a user media video to became black. See an attached video.
I can’t reproduce it on iOS 16.

Demo code: https://github.com/ivan-banha/safari-video-container-resize/commit/7197fb57e9758c81ff482fab7fe210bcf59f87b0

Demo link: https://ivan-banha.github.io/safari-video-container-resize

Demo video: https://github.com/ivan-banha/safari-video-container-resize/blob/main/assets/safari-replace-url-bug.mp4

STR:

  1. Open the link in mobile safari.
  2. Press the “share screen” button.
  3. When a video from a camera appears, press the “replace url” button.
  4. The video should become black.

Is this a bug in safari or expected behaviour?