Skip to content

Bug Report: Intermittent Camera Feed Loss When Repeatedly Starting and Stopping QuickPose in React Native #1

Open
@uatrigger

Description

@uatrigger

Given
A React Native application based on the official QuickPose example:
https://github.com/quickpose/quickpose-react-native-pose-estimation

Functional component architecture
The app includes multiple yoga poses, each of which starts a QuickPose-powered practice session on user click.
Each session ends with closing the screen (e.g., user exits the practice).

Steps to Reproduce
Start a pose session (can be the same or different one each time).
After a delay (from 0 seconds to any arbitrary duration), close the session screen.
Repeat this several times.
The session view uses this SwiftUI code:

var body: some View {
  GeometryReader { geometry in
    ZStack(alignment: .top) {
      if ProcessInfo.processInfo.isiOSAppOnMac,
         let url = Bundle.main.url(forResource: "happy-dance", withExtension: "mov") {
          QuickPoseSimulatedCameraView(useFrontCamera: true, delegate: quickPose, video: url)
            .frame(width: geometry.size.width, height: geometry.size.height)
      } else {
          QuickPoseCameraView(useFrontCamera: true, delegate: quickPose)
            .frame(width: geometry.size.width, height: geometry.size.height)
      }
      QuickPoseOverlayView(overlayImage: $overlayImage)
      // Other UI elements
    }
    .frame(width: geometry.size.width, height: geometry.size.height)
    .edgesIgnoringSafeArea(.all)
    .onAppear {
          quickPose.start(
              features: [],
              onFrame: { status, image, features, feedback, landmarks in
                  switch status {
                  case .success:
                      print("Image updated")
                      overlayImage = image
                  default:
                      break
                  }
              }
          )
      }
      .onDisappear {
        quickPose.stop()
      }
  }
}

Actual Result
In most cases, everything works as expected:
The camera starts correctly.
QuickPose displays overlay data.
The screen renders the live video feed.
But occasionally, the camera fails to show video (white or black screen), while:
QuickPose continues to run and logs pose data to the console.
The module seems functional internally, but the camera feed is missing.
The issue is non-deterministic and appears randomly after repeated session start/stop cycles.

Observations
In the QuickPoseCamera.swift file, if we replace:

output.setSampleBufferDelegate(delegate, queue: qpProcessingQueue)

with:

output.setSampleBufferDelegate(self, queue: qpProcessingQueue)

...then the camera always starts and stops without any issue — video stream is visible and stable.
However, in that case, QuickPose doesn't work (as expected), since it no longer receives the frames.

This indicates that:
The issue is not with camera hardware or session permissions.
The root cause may lie in how the delegate is passed or retained, possibly due to threading or object lifecycle issues.

Expected Result
The camera should always start successfully and display the video stream.
QuickPose should start consistently and deliver overlay image output.
The user should never see a white or black screen.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions