Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Switching camera crashes the app #218

@Mihai-github

Description

@Mihai-github

Describe the bug

I only got the chance to test this on 2 different iOS devices, no Android, but can very well be also there be the same problem while trying to switch the camera the app crashes. While connected to the device using Xcode the crash indicated a different error on each device.

The iPhone 15 Pro Max has this:

Thread 54: EXC_BAD_ACCESS (code=1, address=0x252757cdd810)
A bad access to memory terminated the process.

The iPhone Xs Max has this:

Thread 28: "*** -[AVCaptureMultiCamSession addConnection:] <AVCaptureConnection: 0x283965640> cannot be added because AVCaptureVideoDataOutput only accepts one connection of this media type at a time, and it is already connected"

PS: The iPhone Xs Max was connected with the cable while the 15 Pro Max was through Wifi so maybe the error can be different?

To Reproduce

Steps to reproduce the behavior:

Just implementing the demo example should expose the issue, the relevant lines of code for this are:

const [isCameraFrontFacing, setCameraFrontFacing] = useState(true);

let facingModeStr = !isCameraFrontFacing ? "front" : "environment";
setCameraFrontFacing(!isCameraFrontFacing);
let devices = await mediaDevices.enumerateDevices();
var newDevice;
//@ts-ignore
for (const device of devices) {
  //@ts-ignore
  if (device.kind === "videoinput" && device.facing === facingModeStr) {
    newDevice = device;
    break;
  }
}
if (newDevice == null) {
  return;
}
await room.switchActiveDevice("videoinput", newDevice.deviceId);

Expected behavior

The expected behavior is to be able to switch the camera without any issue.

Screenshots

Device Info:

  • Device: iPhone Xs Max and iPhone 15 Pro Max
  • OS: 15.4.1 and 18.3.2

Dependencies Info (please reference your package-lock.json or yarn.lock file, not just your package.json):

"livekit-client": "^2.9.8",
"@livekit/react-native": "^2.6.1",
"@livekit/react-native-webrtc": "^125.0.9",

Additional context

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions