CameraKit / camerakit-android

Library for Android Camera 1 and 2 APIs. Massively increase stability and reliability of photo and video capture on all Android devices.
https://camerakit.io
MIT License
5.37k stars 880 forks source link

Camera Preview Rotation Bugs #384

Open emersoncloud opened 6 years ago

emersoncloud commented 6 years ago

When the devices is rotated to landscape

Android Device: Pixel XL Android OS Version: 8.1

Official Maintainer Ticket @emersoncloud

DanielNovak commented 6 years ago

We are experiencing the same issue.

DanielNovak commented 6 years ago

Actually switching to front camera and back will fix the distortion.

zhuzhao404 commented 6 years ago

try to use version “0.13.0” sloved

pinigtech commented 6 years ago

The default branch handles landscape better than the 1.0.0 in general

emersoncloud commented 6 years ago

Hey guys, can you test on the newest version 1.0.0-beta3.1? I just tested on a Google Pixel XL with Android 9.0 and I did not have any rotation issues. The implementation details changed a bit so check the bottom of the PR #318 to see how to get it running. Thanks!

pinigtech commented 6 years ago

On One Plus 6 camera preview does not work, with or without rotation in beta3.1. Gives a class definition not found exception. Had reported it in another bug.

On the other branch I have some interesting twists to report. On 0.13.1 and 0.13.2 the portrait works perfectly. The landscape also shows a good preview till you take a picture and then it goes all distorted and crazy. Not twisted enough? It works perfectly ok on 0.13.0 - before and after the click... So I guess there are some regression bugs in that branch as far as One Plus 6 is concerned.

On Thu, Aug 9, 2018, 1:57 AM Emerson Cloud notifications@github.com wrote:

Hey guys, can you test on the newest version 1.0.0-beta3.1? I just tested on a Google Pixel XL with Android 9.0 and I did not have any rotation issues. The implementation details changed a bit so check the bottom of the PR #318 https://github.com/CameraKit/camerakit-android/pull/318 to see how to get it running. Thanks!

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/CameraKit/camerakit-android/issues/384#issuecomment-411540870, or mute the thread https://github.com/notifications/unsubscribe-auth/Aj37SxXQN-H284IlSDfumK0u14lhcn39ks5uO0mYgaJpZM4VlCrE .

emersoncloud commented 6 years ago

@pinigtech Did you add the Kotlin line to the app build.gradle?

repositories {
    maven { url 'https://dl.bintray.com/camerakit/camerakit-android' }
}

dependencies {
    implementation 'com.camerakit:camerakit:1.0.0-beta3.1'
    implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.2.60'
}
pinigtech commented 6 years ago

Ok I was missing the kotlin-stdlib-jdk7:1.2.60 and that's why the no class def error - will test some more update...

On Thu, Aug 9, 2018 at 6:10 AM, Emerson Cloud notifications@github.com wrote:

@pinigtech https://mailtrack.io/trace/link/6b43925b65187775bd3bfe5d71058737a09b209c?url=https%3A%2F%2Fgithub.com%2Fpinigtech&userId=2291577&signature=4a6c026c2c31a68c Did you add the Kotlin line to the app build.gradle?

repositories { maven { url 'https://dl.bintray.com/camerakit/camerakit-android https://mailtrack.io/trace/link/87dc02c04b254c19708b24dff8734fd967d48327?url=https%3A%2F%2Fdl.bintray.com%2Fcamerakit%2Fcamerakit-android&userId=2291577&signature=7681945fc0d7d356' } }

dependencies { implementation 'com.camerakit:camerakit:1.0.0-beta3.1' implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.2.60' }

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://mailtrack.io/trace/link/c1d449c865d0b351ef5ddb53503e9978f2be6509?url=https%3A%2F%2Fgithub.com%2FCameraKit%2Fcamerakit-android%2Fissues%2F384%23issuecomment-411599754&userId=2291577&signature=b5067bcc5c7321b5, or mute the thread https://mailtrack.io/trace/link/cd46e953c3e64342d1a6163474ebad12172324a5?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAj37S-yc6OmbRVfxj70hbA9vAf7TTAGbks5uO4URgaJpZM4VlCrE&userId=2291577&signature=117486a7a325b664 .

pinigtech commented 6 years ago

Ok so here is what I find from the test. The no class def found exception is not coming anymore but the rest of the behavior stays the same:

To elaborate - w ith the same code base, when I change the gradle between 1.0.0..Snapshots and 1.0.0.beta3.1 - the camera preview works in snapshot and shoes a black screen in beta3 .1 :

Camera Preview works with:

repositories { maven { url ' https://dl.bintray.com/camerakit/camerakit-android-snapshots https://mailtrack.io/trace/link/1a817a6c91037c4c6863569fd48fa26c4763737e?url=https%3A%2F%2Fdl.bintray.com%2Fcamerakit%2Fcamerakit-android-snapshots&userId=2291577&signature=91265b4708a48c75' } }

dependencies { implementation 'com.camerakit:camerakit:1.0.0-Snapshot' }

Camera Preview does not work with:

repositories { maven { url 'https://dl.bintray.com/camerakit/camerakit-android https://mailtrack.io/trace/link/00e563417b9e358cac076ab6de2d1c516695e7f8?url=https%3A%2F%2Fdl.bintray.com%2Fcamerakit%2Fcamerakit-android&userId=2291577&signature=7262691e189dfeac' } }

dependencies { implementation 'com.camerakit:camerakit:1.0.0-beta3.1' implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.2.60' }

All of the above is for One Plus 6

On Thu, Aug 9, 2018 at 11:13 AM, Piyush Nigam piyush.n@pinig.com wrote:

Ok I was missing the kotlin-stdlib-jdk7:1.2.60 and that's why the no class def error - will test some more update...

On Thu, Aug 9, 2018 at 6:10 AM, Emerson Cloud notifications@github.com wrote:

@pinigtech https://mailtrack.io/trace/link/ceee7c6bae800e60f3ab175b989cee7b1fea4f4d?url=https%3A%2F%2Fgithub.com%2Fpinigtech&userId=2291577&signature=8410c8dabd47026d Did you add the Kotlin line to the app build.gradle?

repositories { maven { url 'https://dl.bintray.com/camerakit/camerakit-android https://mailtrack.io/trace/link/5257062fc7d876f022a46ba14f7f5d4169c1feac?url=https%3A%2F%2Fdl.bintray.com%2Fcamerakit%2Fcamerakit-android&userId=2291577&signature=a0a6ca02cf642364' } }

dependencies { implementation 'com.camerakit:camerakit:1.0.0-beta3.1' implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.2.60' }

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://mailtrack.io/trace/link/bc6dc97cdd379d187184f46cc0dba68d3d1f91a6?url=https%3A%2F%2Fgithub.com%2FCameraKit%2Fcamerakit-android%2Fissues%2F384%23issuecomment-411599754&userId=2291577&signature=b3550da13bbf254b, or mute the thread https://mailtrack.io/trace/link/4e4daf79fa92d2a2c610d78e5e8f59d4d6c8a6da?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAj37S-yc6OmbRVfxj70hbA9vAf7TTAGbks5uO4URgaJpZM4VlCrE&userId=2291577&signature=2bf4534832d4939e .

glenatron commented 5 years ago

I'm still seeing this exact problem on my Sony XPeria - everything goes weird after rotation. CameraKit seems really good but this is a showstopper for me- if I know what the correct rotation is supposed to be, is there any way I can manually fix up CameraView?

emersoncloud commented 5 years ago

Hey @glenatron, check out #427 for a possible solution for this issue. Try removing the following from your AndroidManifest.xml.

<activity>
    android:configChanges="orientation|screenLayout"
</activity>
glenatron commented 5 years ago

Thanks for the tip! I saw that previously and unfortunately in my case removing that doesn't appear to make any difference.

glenatron commented 5 years ago

My situation is very like that described in #427 in that I have the CameraKitView in a fragment in a CameraPreviewActivity which is not my main activity.

HBiSoft commented 5 years ago

@emersoncloud

I have the same issue, using Samsung J7 Pro running 8.0.1 .

In my case the Activity gets recreated causing camera to close and open again since onPause/onResume gets called.

When I start my Activity in landscape and rotate to portrait then the issue doesn't appear, but switching back to landscape cases the rotation to be incorrect.

My manifest:

<activity android:name=".CamActivity"
        android:theme="@style/Theme.Transparent" /> //Removing titlebar

I'm using version implementation 'com.wonderkiln:camerakit:0.13.2' because I'm only interested in capturing video.

The issue doesn't appear for me on the demo application (on Google Play) and it's using 0.13.2 same as I'm using.

HBiSoft commented 5 years ago

@emersoncloud

Just tested again, setting android:screenOrientation="portrait" in manifest, as shown below:

<activity android:name=". CamActivity"
        android:theme="@style/Theme.Transparent"
        android:screenOrientation="portrait"/>

solves the problem, but it introduces a new problem.

When the parent Activity is in landscape and I open the Activity that holds the CameraView, in my case CamActivity, I get the following result:

Screenshot_20190521-082236_LogCameraError

The white background and the green button (at the bottom) is from the previous Activity. Also, the device is currently in landscape mode.

If I rotate the device back to portrait, the preview remains as in the image above.


I have also noticed that when I'm in portrait mode while opening the Activity that hold the CameraView, the preview is first shown on only half of the screen, as shown below:

Screenshot_20190521-083111_LogCameraError

This only happens for about 0.5 seconds, whereafter I get the correct result.

HBiSoft commented 5 years ago

I also think it's worth mentioning that the same happens in the demo application when the device is in landscape mode at the time of opening the application, here is the result:

Screenshot_20190521-084044_CameraKit

HBiSoft commented 5 years ago

I just tested on multiple devices, I believe anyone using this library should be able to replicate this issue. Simple start the Activity that is holding the CameraView in landscape mode.

All the devices I have tested on produce the same result.

Here is a gif demonstrating it in the demo application:

Opening the app in portrait mode works fine -

portrait

Where as opening the app while the device is in landscape mode, causes the following:

landscape

This issue has been open for 10 months now and in my honest opinion, it's not a small bug that can be ignored, all users that has this library implemented in their app must have experienced this issue. If not, then they didn't debug their app properly.

I tested on beta3.11 and it seems like the issue has been resolve, but I can't take video with beta3.11?