Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Black area when CameraView is resized (using SurfaceViewPreview) #41

Closed
Monster-king opened this issue Sep 12, 2017 · 12 comments
Closed
Labels

Comments

@Monster-king
Copy link

Monster-king commented Sep 12, 2017

Width: 1080
Height: 1080
image

@natario1
Copy link
Owner

So you just open app then set these dimensions?

@Monster-king
Copy link
Author

First i created my own app with your library, it has same issue. Then I clone your example, and it has same issue too.

@natario1
Copy link
Owner

@Monster-king You didn't answer though :) please use the demo app, then describe clearly the steps to reproduce the bug, then post the logs you see in the logcat. The demo app will log a lot of useful things.

@Monster-king
Copy link
Author

Monster-king commented Sep 16, 2017

@natario1 At the moment I've installed the app to my Samsung J1 2016 phone, changed the height to 480 (because in width is 480 too). When I pressed the update button I took the message "Height updated! Internal preview size: 640x480". Preview has black area like that screen. Here all logs.
new 2.txt

@natario1
Copy link
Owner

@Monster-king thanks!
I just think the camera XML is wrong actually. Can you try modifying it?

If you open activity_main.xml you can see that CameraView is wrapped in a RelativeLayout. That makes no sense. Can you remove the relative layout and try again?

@Monster-king
Copy link
Author

@natario1 Relative layout removed, nothing changed.

@natario1
Copy link
Owner

That's disappointing :) I don't know what's wrong right now, but CameraView looks to be measuring itself correctly. For the moment I guess you can just avoid to apply runtime changes to width / height. Or if you really need it, ensure you call requestLayout() on the view or on its parent.

If you have some time, you could do the following test:

  • add background="@color/red" to the RelativeLayout
  • add background="@color/green" to the CameraView
  • add to other views if you wish

Then tell me what colour you see in that area that is black now. Just to see what it belongs to. If it's red, then what if you remove the RelativeLayout?

@natario1
Copy link
Owner

Nevermind, I was able to reproduce on another device. I will take a look myself

@natario1
Copy link
Owner

So, this is a bug with low end devices that have isHardwareAccelerated() return false.

In that case CameraView will render in a SurfaceView (instead of TextureView) and we are not able to provide center crop behavior for surface views.

The current workaround for these devices is to use wrap content for both dimensions.

@natario1 natario1 changed the title Black area when cameraview resized squared Black area when CameraView is resized (using SurfaceViewPreview) Sep 16, 2017
@Monster-king
Copy link
Author

I don't think so, because preview looks like compressed by height. Do you tested it in another device?

@natario1
Copy link
Owner

@Monster-king can you try now? Demo app has changed and also a surface bug was fixed.

@Monster-king
Copy link
Author

@natario1 Fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants