ReactVision / viro

ViroReact: The AR and VR library for React Native πŸ“³πŸ’™πŸ’›πŸ€πŸ’š
MIT License
1.3k stars 150 forks source link

Video doesn't stop on most of iPhone/iOS versions when AR scene is unmounted causing memory leaks #286

Open Buthrakaur opened 3 months ago

Buthrakaur commented 3 months ago

Environment

Please provide the following information about your environment:

  1. Development OS: Mac
  2. Device OS & Version: iOS 15, 16
  3. Version: ViroReact version 2.23.1 and React Native version 0.71.3
  4. Device(s): iPhone SE iOS 15.x, iPhone 8, iOS 16.5.1

Description

Video playback doesn't stop when AR scene is unmounted and the audio keeps playing after the scene is unmounted causing memory leak of AVPlayer instance. We tried to resolve this by pausing the playback when on AR scene unmount but it doesn't prevent memory leak of the AVPlayer instance. We tried this on multiple iPhones with mixed results:

Reproducible Demo

Just use a simple AR scene with ViroVideo component opened from a screen in the app.

    <ViroARScene onCameraTransformUpdate={onCameraTransformUpdate} onTrackingUpdated={onInitialized}>
       <ViroVideo
            position={offsetPosition}
            loop={feature.loop}
            rotation={objectRotation}
            width={feature.size.width}
            height={feature.size.height}
            source={feature.source}
            onBufferEnd={onLoadEnded}
            onError={onLoadFailed}
          />
    </ViroARScene>

issue in the old repo: https://github.com/viromedia/viro/issues/1005

linear[bot] commented 3 months ago

XR-195 Video doesn't stop on most of iPhone/iOS versions when AR scene is unmounted causing memory leaks