apiko-dev / amazon-ivs-react-native-broadcast

A React Native wrapper for the Amazon IVS iOS and Android broadcast SDKs
MIT License
25 stars 13 forks source link

Camera flashing and 'freezes' on iPhone X #12

Open chrisedington opened 1 year ago

chrisedington commented 1 year ago

Hi @AndrewShapovalov

Me again 😅 I found an issue where on two sets of iPhone X and using the sample, the camera flashes green colors and freezes.

https://user-images.githubusercontent.com/2725500/202445677-8802a520-f814-41a5-bf1d-9190ad68b545.MOV

image

AndrewShapovalov commented 1 year ago

Hi @chrisedington!

Thanks for the info. Do you have any chance to provide logs?

chrisedington commented 1 year ago

@AndrewShapovalov can try - what source or kind of logs would you be looking for?

AndrewShapovalov commented 1 year ago

@AndrewShapovalov can try - what source or kind of logs would you be looking for?

Debug logs from Xcode (Debug area) while the problem happens.

AndrewShapovalov commented 1 year ago

Hi @chrisedington!

Some update from my side - tried to reproduce the bug on iPhone X with iOS version 16.1 but without luck.

wizfinder commented 1 year ago

I have same problem. I write Test Environment and Error log below.

Test Env.
Device: iPhone 11, iOS 15.6.1 
Video Resolution: 720x1280
 Bug Reproduce 
when preview screen's size is matched on iphone screen. It happened image capture action is too slow or flashing.

Debug Log:
 2023-01-04 17:08:15.173949+0900 ivsTest[3973:200261] Execution of the command buffer was aborted due to an error during execution. Ignored (for causing prior/excessive GPU errors) (00000004:kIOGPUCommandBufferCallbackErrorSubmissionsIgnored)
 ...... above message is repeated

AndrewShapovalov commented 1 year ago

Hi @wizfinder, thanks for the report!

Is the same or any other error in the onBroadcastError event handler?

AndrewShapovalov commented 1 year ago

Hi @chrisedington @wizfinder! Me again.

It appears to be an internal issue, but since I am unable to reproduce it, could you please check the repository containing sample native apps that use the Amazon IVS Broadcast iOS SDK and see if you can reproduce the problem by running BasicBroadcast sample app?

wizfinder commented 1 year ago

Hi @chrisedington @wizfinder! Me again.

It appears to be an internal issue, but since I am unable to reproduce it, could you please check the repository containing sample native apps that use the Amazon IVS Broadcast iOS SDK and see if you can reproduce the problem by running BasicBroadcast sample app?

When I build BasicBroadcast and run, I don't have errors. Only I have errors in ReactNative env with iPhone 11. and In iPad Mini(6 Gen.), I don't have errors in ReactNative env.

AndrewShapovalov commented 1 year ago

@wizfinder hi! Thanks for the update!

Do you face the same type of error by running Amazon IVS React Native Broadcast Example App?

Could you also provide detailed props configuration you pass to IVSBroadcastCameraView component (e.g. videoConfig, audioConfig, configurationPreset and others) please?

wizfinder commented 1 year ago

I don't face the same error with Aws IVS ReactNative Broadcast Example App.

I wrote test code below. if width and height value are less than about 300, it works well.

 const videoConfig = {
    width:720,
    height:1280,
    bitrate: 7500000,
    targetFrameRate: 30,
    keyframeInterval: 2,
    isBFrames: true,
    isAutoBitrate: true,
    maxBitrate: 8500000,
    minBitrate: 1500000
  }

......

<SafeAreaView>
  <IVSBroadcastCameraView style={{width:"100%", height:"100%"}}  
  //<IVSBroadcastCameraView width={300} height={300}
        ref={cameraViewRef}
        videoConfig={videoConfig}
        onIsBroadcastReady={onIsBroadcastReadyHandler}
        onBroadcastAudioStats={onBroadcastAudioStatsHandler}
        onBroadcastError={(e) => console.log("onBroadcastError", e)}
        onBroadcastStateChanged={(stateStatus, metadata) => console.log("onBroadcastStateChanged", stateStatus, metadata)}
        cameraPreviewAspectMode={"fit"}
  />
</SafeAreaView>
codal-mpawar commented 1 year ago

@wizfinder @chrisedington I am facing the same issue too.

AndrewShapovalov commented 1 year ago

I don't face the same error with Aws IVS ReactNative Broadcast Example App.

According to the answer you've provided, it appears that the issue might be within the project's codebase rather than with the package. Try experimenting with your component that utilizes the IVSBroadcastCameraView and configuration to identify possible issues.

I will also play around with the sample app using iPhone 11 to catch any related problems. @wizfinder

rennard commented 1 year ago

Also having this issue, I've not yet been able to find any form of workaround

cowlabs-xyz commented 1 year ago

Hi,

We had the same issue and found that setting the width and height of broadcast to 320 worked for iPhone6 and around 400->500 on iphonex. If not the component will flash or hang.

Have not looked into the underlying native code to understand what is causing it yet.

Kim

kimdanielarthur-cowlabs commented 1 year ago

I have been testing a variety of configuration changes and it seems somehow related to the total number of pixels being rendered? I have been unable to find any workaround for the affected devices other than reducing streaming quality, so on iphone6/7 its 320p which would be great to increase :)

Anyone had any luck figuring it out?

dongchan0321 commented 1 year ago

Hi, @AndrewShapovalov I'm encountering the same issue with the Amazon IVS React Native Broadcast Example App. I've reproduced the problem on an iPhone XS (iOS 16.0.3) and an iPad Mini 5 (iPadOS 16.6). Following the IVS Broadcast SDK guidelines, I made some code modifications and the issue no longer occurs; everything runs smoothly.

// ios/IVSBroadcastCameraView/IVSBroadcastSessionService.swift

private func getCameraPreview() -> IVSImagePreviewView? {
  // let preview = try? self.broadcastSession?.previewView(with: self.cameraPreviewAspectMode)
  // preview?.setMirrored(self.isCameraPreviewMirrored)
  // return preview
  let preview = try? self.broadcastSession?.listAttachedDevices().compactMap({ $0 as? IVSImageDevice }).first?.previewView(with: self.cameraPreviewAspectMode)
  preview?.setMirrored(self.isCameraPreviewMirrored)
  return preview
}

Could you please review the changes to see if there might be any potential drawbacks?

kimdanielarthur-cowlabs commented 1 year ago

Thanks @dongchan0321 for this potential fix, did you have any experience with your change and if it all works ok with this implementation?

dongchan0321 commented 1 year ago

I have tested the prolonged video streaming push on the same device where the issue was originally reproduced, and I haven't encountered any new problems so far. I plan to conduct further testing using devices of different models. I am not a professional iOS developer, and this code segment originates from the IVS Broadcast SDK. After consulting the documentation, I was unable to identify the root cause of the issue.

Thanks @dongchan0321 for this potential fix, did you have any experience with your change and if it all works ok with this implementation?

kimdanielarthur-cowlabs commented 1 year ago

Thank you for replying! Yes I have tested on the devices we had issues with before and it seems to work perfectly. Now, we will also do some more testing across devices to validate before pushing it into production.

Very happy you found this, as its been a bit of a hindrance for us. Even on devices like iphone 11 pro we had to reduce resolution of streaming in order to work around the issue.

AndrewShapovalov commented 1 year ago

Hello everyone,

Thank you all for your valuable input and code suggestions. I've taken your feedback into consideration and made changes to the same getCameraPreview method. Instead of using the first attached device in the list, I now use the attachedCameraUrn variable, which I believe is a more robust solution.

You can now try out these changes via NPM using the next dist-tag.

yarn add amazon-ivs-react-native-broadcast@next

Please, give it a try and provide feedback on your experiences.

dongchan0321 commented 1 year ago

Hello everyone,

Thank you all for your valuable input and code suggestions. I've taken your feedback into consideration and made changes to the same getCameraPreview method. Instead of using the first attached device in the list, I now use the attachedCameraUrn variable, which I believe is a more robust solution.

You can now try out these changes via NPM using the next dist-tag.

yarn add amazon-ivs-react-native-broadcast@next

Please, give it a try and provide feedback on your experiences.

Hello, thank you for your fix. After conducting a brief real-device test, we have found that the devices that previously had issues are now functioning correctly. We have limited time for further testing at the moment, but we plan to perform additional validation with more devices in the future.

kimdanielarthur-cowlabs commented 11 months ago

As an fyi: With the new code from next it seems the ios simulators are unable to get the camera preview. Whereas it works ok on devices. I am unsure if this is some behaviour locally on my side or not, using latest xcode.

wulaizi commented 10 months ago

I used amazon-ivs-react-native-broadcast, and after running pod install, the project crashed immediately. My Xcode version is 14.3, and I'm using the iOS 14 Pro simulator with macOS version 16.4.

Snipaste_2023-10-30_11-28-56
wulaizi commented 10 months ago

I used amazon-ivs-react-native-broadcast, and after running pod install, the project crashed immediately. My Xcode version is 14.3, and I'm using the iOS 14 Pro simulator with macOS version 16.4. Snipaste_2023-10-30_11-28-56 I encountered the same issue with the demo project provided by the amazon-ivs-react-native-broadcast library. I also created an empty project, added amazon-ivs-react-native-broadcast as a dependency, and faced the same error.