videokit-ai / videokit

Low-code, cross-platform media SDK for Unity Engine. Register at https://videokit.ai
https://videokit.ai
Apache License 2.0
107 stars 14 forks source link

Camera Orientation Incorrect on Pixel 6 #45

Closed cwnuk-lfl closed 5 months ago

cwnuk-lfl commented 1 year ago

On the Pixel 6, we are seeing the front facing camera image rotated 90 degrees counter clockwise.

This previously worked as expected on this device, but the behavior changed when we upgraded to the latest version of Android available on the device. Other devices we have tested (see below) have not exhibited this issue, but do not seem to have the same OS updates available to them yet.

When we start the camera, we are seeing this spamming the console in logcat on the Pixel 6: 2023/07/05 13:48:46.260 31104 31278 Error ACameraMetadata getConstEntry: cannot find metadata tag 65568 This log message does not seem to appear on devices without the issue.

Consistent across all below tests:

Unity 2021.3.24f1
`Default Orientation` set to Landscape Left in Unity Resolution and Presentation Player Settings
NatDevice 1.3.1 and 1.3.4 were both tested with the same results
Minimum Android API Level 24
IL2CPP
API Compatibility Level: .NET Framework
Graphics APIs: OpenGLES3, Vulkan
Linear Color Space
URP

Configurations tested, where the issue does occur:

Pixel 6
Android 13
March 5, 2023 security update
Google play system update May 1, 2023
Kernel 5.10.149-android13-4-00004-g0e5c0e91bbee-ab947504
Issue present with 'Auto Rotate screen' both enabled and disabled in device's Settings/Display menu

Configurations tested, where the issue does not occur:

Pixel 6
Android 13
Dec 5, 2022 security update
Google play system update May 1, 2023
Kernel 5.10.107-android13-4-00038-ga6f610f1f1e6-ab9083768
Samsung galaxy S7
Android 13
July 1, 2023 security update
Google play system update: May 1, 2023
Kernel 4.19.113-26430179, natmlx/natdevice#1 wed apr 19 14:13:54 +07 2023
Samsung s22 ultra
Android 13
June 1, 2023 security update
Google play system update: may 1, 2023
kernel version: 5.10.136-android12-9-26203684-abs908usqu2cwe6

Mac & Windows in editor working as expected

iPhone 13 Pro & other iOS devices working as expected

olokobayusuf commented 1 year ago

Hey @cwnuk-lfl , I've got inline responses below:

This previously worked as expected on this device, but the behavior changed when we upgraded to the latest version of Android available on the device. Other devices we have tested (see below) have not exhibited this issue, but do not seem to have the same OS updates available to them yet.

This is gonna be a tough one to find a workaround for, given that it's both device- and OS-version-specific.

When we start the camera, we are seeing this spamming the console in logcat on the Pixel 6: 2023/07/05 13:48:46.260 31104 31278 Error ACameraMetadata getConstEntry: cannot find metadata tag 65568 This log message does not seem to appear on devices without the issue.

I don't think this is related. Metadata tag 65568 should correspond to ACAMERA_CONTROL_AF_STATE (i.e. autofocus state).

A quick diagnostic to run is to check the cameraDevice.frontFacing of the front camera on the Pixel 6. If that value is incorrect, then that would both be the culprit and the place to build a workaround.

cwnuk-lfl commented 1 year ago

Hi @olokobayusuf thank you very much for the response! cameraDevice.frontFacing is reporting as true.

olokobayusuf commented 1 year ago

@cwnuk-lfl this is going to be pretty involved to investigate and potentially fix. Shoot me an email to discuss further.

cwnuk-lfl commented 1 year ago

Thanks @olokobayusuf - emailed you at that address.

olokobayusuf commented 1 year ago

NatDevice has officially been deprecated, as it has been merged into VideoKit. I'm moving this issue to the VideoKit repo.

olokobayusuf commented 5 months ago

While we haven't added an explicit fix for this issue, we've exposed new APIs that will allow developers to write a workaround. Feel free to follow up for more info on doing this.