yasirkula / UnityNativeCamera

A native Unity plugin to take pictures/record videos with device camera on Android & iOS
MIT License
607 stars 71 forks source link

Take Picture with AR Kit does not work and also shows a black screen (iOS only, ocurring on some devices) #84

Open marcolbx opened 2 years ago

marcolbx commented 2 years ago

Description of the bug When using AR Kit and trying to take a picture, the camera would appear black and would not actually work, since we have a black screen, we assume that the camera stream is not taken correctly. It seems like AR Kit locks the camera and would not allow other plugin to work on it. However, the video camera is actually working on all devices. Which makes us think that the problem could be on the TakePicture process somehow.

The same build was tested on the following devices: List of devices that DO NOT have the problem iPad 6 - iOS 13.4 iPad 6- iOS 14.3 iPad 7 - iOS 14.5 iPad Pro 11

List of devices that HAVE the problem: iPad 8 - iOS 14.4 iPad 8 - iOS 15.3

Reproduction steps

Use AR Kit on your iOS device, make a button with the Take Picture method of the example and try to take a picture. (Beware that if the problem does not happen, then your device could be on the white list. However if you could add the specs it would be helpful)

Additional info

Something that is curious: working: iPad 7 : A10 Fusion chip iPad 6: A10 Fusion chip iPad Pro 11 (2020): A12Z Bionic chip not working: iPad 8: A12 Bionic chip iPad 8: A12 Bionic Chip

marcolbx commented 2 years ago

I did find a workaround but it would be better if we did not use it. Turn off AR Session before taking a pic and turn it back on after the picture was taken.

yasirkula commented 2 years ago

It's probably related to two processes not being able to use the camera simultaneously. My theory is that, on working devices, different rear cameras are used for photos and videos (some devices have multiple rear cameras).

Why don't you grab a screenshot from the AR camera in Unity, wouldn't that be the same thing as opening NativeCamera?

marcolbx commented 2 years ago

the comparison of the devices does not seem to show that there are multiple rear cameras. From iPad 7 to iPad 8 there is almost no difference.

yasirkula commented 2 years ago

I see. I unfortunately have no other theories at the moment.