With every new phone release there’s bound to be a few bugs or issues worked around and Google’s Nexus phones are no different. The latest issue to come to light is that the camera module on the Nexus 5X has been mounted in a not too standard way, which has caused issues for apps using the original camera API.
The issue came to light after the developer of QR & Barcode Scanner received an email from LG support asking him to implement new code in his app due to the camera being upside down. The developer posted the interaction to reddit, where it gets interesting, because the tech lead for Android’s camera framework replied with an in-depth explanation of what’s actually happening.
According to the reply, it turns out that the camera module actually is upside down – or in the developers words in ‘(reverse landscape) orientation’ due to the way the camera module needed to be wired up – there wasn’t room to fit the wires the ‘right’ way up. The flip side is that the older Camera API that some developers are still using requires developers to set preview rotation, which if the camera is the right way up, is fine – but since the Nexus 5X camera is in an odd orientation leads to issues – this is also why some apps last year were showing upside down previews last year (I`m looking at you Periscope).
The full explanation from the thread, is an interesting read
Image sensors on a compliant Android device can be mounted in one of two ways. Most devices use one way, so a lot of camera apps have never been tested on devices that pick the other way.
Because of manufacturing reasons, we needed to mount the Nexus 5X main sensor in the less-common (reverse landscape) orientation – the wires from the sensor chip wouldn’t have fit otherwise.
Unfortunately, our old camera API (which is deprecated, but most apps still use it) isn’t terribly user-friendly, and requires application developers to explicitly set the preview rotation. On most devices, though, it turns out the default rotation is correct for a forced-landscape app, so many apps never call the display orientation method.
The new camera2 API handles the rotation automatically for developers, but until they move to the new API, apps need to use the boilerplate we have in the developer docs to check the sensor and UI orientation, and apply the right rotation:http://developer.android.com/reference/android/hardware/Camera.html#setDisplayOrientation(int)
We tried to work out a way to adjust the default so that apps wouldn’t have to deal with this, but unfortunately changing it would have broken apps that do call this method.
This is also why a number of apps showed upside down preview on the Nexus 6 front-facing camera last year – it’s also in the less-common orientation. But far fewer apps support the front-facing camera than the back-facing one, so it was less of an issue than it is for Nexus 5X.
So if you do see apps with upside-down camera preview on Nexus 5X, please let the developers know about this – Android’s developer relations folks are trying to reach out to apps as we find them, and LG is also helping out, but it might take a bit before everyone’s up to speed on this issue.
So. If you’re loading a camera app on your brand new Nexus 5X and there’s upside down images, might be time to send the developer an email with a link to the reddit thread.