api.video-reactnative-live-stream icon indicating copy to clipboard operation
api.video-reactnative-live-stream copied to clipboard

Camera in use indicator doesn't go away

Open endrits079 opened this issue 3 years ago • 12 comments

After calling stopStreaming() the onDisconnect event successfully fires and the streaming is stopped, although my phone is still showing a green color that indicates camera is still in use and only goes away if I entirely close the application, what is the problem?

Versions: "@api.video/react-native-livestream": "^1.0.0", "react-native": "0.66.4",

Testing device: iPhone XS ios 15.4.1

endrits079 avatar May 01 '22 15:05 endrits079

Hi,

Yes, indeed the preview is still running on background. This is definitely a bug and it only happens in iOS: we don't stop camera preview when going to background. We already fix that issue in develop. Unfortunatly there is still a crash on Android and to fix this one, we will have to update react native framework. This is something we haven't succeeded yet.

Regards, Thibault

ThibaultBee avatar May 02 '22 08:05 ThibaultBee

Hi,

We released v1.1.0 that should fix the issue. Could you give v1.1.0 a try?

Best regards, Thibault

ThibaultBee avatar May 09 '22 14:05 ThibaultBee

Hi,

We released v1.1.0 that should fix the issue. Could you give v1.1.0 a try?

Best regards, Thibault

Hello, I updated to 1.1.0 but unfortunately the indicator still doesn't go away. Tested on iPhone XS ios 15.4.1

endrits079 avatar May 09 '22 19:05 endrits079

Hello, The green color means that camera is still running. As long as the camera is running (even only previewing). It disappears only if you send your application to background (just tested it). Maybe your pods have not been updated. Could you verified in your Podfile.lock if iOS ApiVideoLiveStream version is 0.2.1?

ThibaultBee avatar May 10 '22 07:05 ThibaultBee

Hello, The green color means that camera is still running. As long as the camera is running (even only previewing). It disappears only if you send your application to background (just tested it). Maybe your pods have not been updated. Could you verified in your Podfile.lock if iOS ApiVideoLiveStream version is 0.2.1?

Hi, indeed sending the app in the background it removes the green color, but isn't it possible to remove that without having to close the app? isn't that supposed to happen on stopStreaming() call?

endrits079 avatar May 10 '22 09:05 endrits079

No it is not possible. iOS displays the green light as soon as the camera is running. It is not something we can change. You have the same behavior with the native camera application. See https://support.apple.com/en-gb/HT211876 There is nothing we can do about it: closing the issue.

ThibaultBee avatar May 10 '22 09:05 ThibaultBee

No it is not possible. iOS displays the green light as soon as the camera is running. It is not something we can change. You have the same behavior with the native camera application. See https://support.apple.com/en-gb/HT211876 There is nothing we can do about it: closing the issue.

But going to another screen where the component is not mounted anymore the camera shouldn't be running?

endrits079 avatar May 10 '22 10:05 endrits079

You are right. I haven't thougth of that case. It is something I need to investigate. In the worst case scenario, we will add stopPreview method.

ThibaultBee avatar May 11 '22 09:05 ThibaultBee

Any update on this issue? Camera is running in the background even if you are on another screen and its drain the battery.

tarun-showday avatar Aug 09 '22 05:08 tarun-showday

If anyone wants to take up this issue. I have two non-working projects where this issue was resolved. v1 I cant remember why i had to abandon this one. v2 The preview would stop after the first frame had been rendered.

I remember having this issue, but dont remember how it was fixed. And couldnt find what i had done different back then to fix it.

BlueBazze avatar Aug 22 '22 12:08 BlueBazze

@BlueBazze That would be really great if you remember how you did fix this issue :)

Does anyone know how to detect that an UIView is being put to background from a RN iOS part? I can't find anything :(

ThibaultBee avatar Sep 02 '22 13:09 ThibaultBee

It seems that overriding removeFromSuperview in ReactNativeLiveStreamView could do the job like this:

override public func removeFromSuperview() {
        super.removeFromSuperview()
        liveStream.stopPreview()
}

We will have to add a stopPreview and a startPreview API in https://github.com/apivideo/api.video-ios-live-stream

ThibaultBee avatar Sep 02 '22 14:09 ThibaultBee

@ThibaultBee any progress in this issue?

endrits079 avatar Sep 16 '22 16:09 endrits079

Would really appreciate if there is any solution for this issue. We have used the library in production and would have to revert to an older version of our app because of the green light and the iOS crashes. Presently the following happens with the app

  1. LiveStream gets mounted and the green and yellow light come up
  2. If I start the stream, then stop the stream and navigate out, then 2 out of 10 times the light goes off.
  3. Rest of the time it stays in.
  4. If I navigate back to the LiveStream component, it sometimes crashes and sometimes it doesn't.

I will investigate further and share crash logs from XCode. Thank you

rahul2992 avatar Sep 24 '22 11:09 rahul2992

Hi,

I already added stopPreview and startPreview in iOS live stream. Still missing the removeFromSuperview and tests.

ThibaultBee avatar Sep 26 '22 11:09 ThibaultBee

I have tried to make a fix. I am not 100 % that will fix this issue. Can anyone test https://github.com/apivideo/api.video-reactnative-live-stream/tree/bugfix/background_preview?

ThibaultBee avatar Sep 29 '22 15:09 ThibaultBee

This should be fixed in v1.2.1

ThibaultBee avatar Oct 12 '22 12:10 ThibaultBee