aframevr / aframe

:a: Web framework for building virtual reality experiences.
https://aframe.io/
MIT License
16.58k stars 3.93k forks source link

Random page reloads in iOS while streaming webcam to video #4624

Open genekogan opened 4 years ago

genekogan commented 4 years ago

This is the exact same problem reported in issue 2782 in 2017 and originally resolved with this commit. I am experiencing this issue again, possibly for a different reason.

My application streams video to aframe from a remote server using WebRTC. Everything works fine until I enter VR mode and rotate the phone to landscape. It continues to work as expected, streams reliably in VR mode, and looks fine, but after 10-20 seconds, the webpage randomly refreshes.

Note that the 360-video example which this is based on, does not have the issue, so the refresh is not triggered with a normal

<html>
<head>
    <meta charset="UTF-8"/>
    <meta name="description" content="A-Frame webcam">
    <title>Aframe webcam</title>
    <script src="https://aframe.io/releases/1.0.4/aframe.min.js"></script>
</head>
<body>

<a-scene>
    <a-assets>
        <video id="video" autoplay="true" crossOrigin="anonymous"></video>
    </a-assets>
    <a-videosphere src="#video" rotation="0 180 0"></a-videosphere>
</a-scene> 

<script>
    window.addEventListener('click', function () {
      var video = document.querySelector('#video');
      if (video.paused == true) {
        video.play();
        } else {
        video.pause();
      }
    }, false);

  </script>

</body>
</html>
dmarcos commented 4 years ago

Are there any error messages in console?

dmarcos commented 4 years ago

The refresh might be caused by a tab crash related to video playback over WebRTC as you mentioned.

genekogan commented 4 years ago

No console errors that I can see. If it is a video playback error from the server, is there some way on the client side to catch an exception so as to avoid the crash?

I've been able to fix the issue simply by disabling the iOS wake lock function in aframe, but I'm afraid doing this introduces a new problem?