apivideo/api.video-reactnative-live-stream

Defaulting with front camera is very slow to start

soemarko opened this issue · 10 comments

Describe the bug
As titled, if I set the default camera to be front, it is much slower compared to defaulting to back camera.

To Reproduce
Steps to reproduce the behavior:

  1. Set the broadcast screen as part of Stack Navigation
  2. Set the default to front camera const [camera, setCamera] = React.useState<'front' | 'back'>('front');
  3. Navigate to the broadcast screen

Expected behavior
The screen should open at least as fast as defaulting to the back camera.

Screenshots
If applicable, add screenshots to help explain your problem.

Smartphone (please complete the following information):

  • Device: iPhone 13 Pro
  • OS: iOS 15.x
  • Version 1.2.1

Additional context
Add any other context about the problem here.

Hi,

I did notice it too.
I guess this comes form the fact that call to attachCamera and prepareConfig are all on the same thread. Moreover, an attachCamera on the back camera is always perform even if the user wants to start on the front camera.

This is something we should fix. Unfortunately, we are busy on other projects at the moment.

@soemarko - I'm facing the same issue.
My workaround solution is to put up an activity indicator while the user waits.
In addition, you can speed up the loading time by mounting the camera with the 'back' value, then flipping the camera to 'front' after the camera has mounted. Not perfect, but drastically improves the UX.

I'm not facing this issue on Android, so i've set this workaround to only happen on ios.

Also @ThibaultBee if you can point me in the right direction for attachCamera and prepareConfig, maybe i can help out. I can't seem to find either of these two values in the codebase.

And big thank you for your work on this.

Hi,

attachCamera and prepareConfig are in a dependency: https://github.com/apivideo/api.video-ios-live-stream/blob/main/Sources/ApiVideoLiveStream.swift

My idea is to add a initialCamera: AVCaptureDevice.Position? in the init.
If the initialCamera is optional then the default camera is not started (attachCamera not called).

Unfortunately, we don't have much time for this.

Hi,

Could you check that your issue is fixed in the main branch?

Oh no... this is worse. even back camera is slow now and I feel like it is slower than before.

Hi,

With the upgrade of the internal live stream library, there has been few regressions. Could you test again on the main branch?

I've uninstalled the old one, and added it with yarn add @api.video/react-native-livestream@https://github.com/apivideo/api.video-reactnative-live-stream is this not the main branch?

Screenshot 2023-01-10 at 5 27 07 am

And the pod install

Installing ApiVideoLiveStream (1.3.0)
Installing HaishinKit (1.4.1)
Installing Logboard (2.3.0)
Installing react-native-live-stream (1.2.1)

Did I do it wrong?

Not sure... but ApiVideoLiveStream should be 1.3.1. You could try a pod update

but ApiVideoLiveStream should be 1.3.1.

Yes! This is it! Totally fixed. Dim a bit before it snapped on, but super fast! Thank you very much!

This should be fixed in v1.2.2.