I have a rather odd regression betweeen alpha07 an...
# compose
n
I have a rather odd regression betweeen alpha07 and alpha11. I had followed some instructions on how to integrate with CameraView from CameraX using an AndroidView, and specifically I had implemented a preview use case, and had scaled the CameraView into a small thumbnail just as a view-finder for what the camera was looking at. This worked fine in alpha07, but in alpha11 it looks like the surface is being cropped instead of scaled as I was expecting. It'd take me a bit to make a minimal reproduction case, and will in the thread if required. Any ideas from the compose authors here on why a SurfaceView would be clipped now instead of scaled as before?
👀 1
Alright, I spent a bit of time to make a minimal example app, and put the code up on Github: https://github.com/nealsanche/ComposeCameraPreview there are two commits, one that targets alpha08, and one that targets alpha11 of Compose. In the alpha11 version, the camera preview always starts out unscaled as if the surface is being actually drawn full screen, but is clipped. Flipping the switch on the app toggles between front and back cameras, and after toggling, the preview looks correct. On alpha08 the preview always looks fine, even at startup.
This is an example of what I'd expect to see, the camera preview fits inside the thumbnail.
And here is what the initial layout looks like on alpha11. The preview is cropped, instead of being scaled as I would expect.
a
hmm. Can you file a bug on the compose issue tracker linking to that repo? We may not get to investigating it in the next week or so but it looks like something worth tracking if it's still giving you trouble.
f
@Neal Sanche Would you mind sharing the link to bug report if you get the time to report it? 🙂
👍 1
@Neal Sanche Also you can force use of TextureView instead of SurfaceView as workaround. This seems to work correctly:
Copy code
view.implementationMode = PreviewView.ImplementationMode.COMPATIBLE
n
Will do, @Adam Powell.
@fmasa Nice, I'll try the workaround. It'll probably be fine. Will still post a bug report though and put the link here.
f
I just now noticed that the preview (in my case at least) is not really cropped, but rather scaled and then shrunk
i
Hi @Neal Sanche, did you find a solution for this issue? I think I have the same issue but using the CameraX and AndroidViewBinding. I also found that this issue is somehow related to the android coroutine lib.
n
Nothing so far, Ilias. I was going to go back and try the above workaround to see if it works for Compose, but I haven't yet.
i
TextureView fixed the issue for me. Working with Camera X in compose brings many issues, especially for older devices.
n
I also can confirm that using TextureView using the workaround above, definitely works for my little app. Thanks @fmasa.
a
This problem happened to me also, and workaround solution is also worked for me. I hope it will be handled. Thank you so much @fmasa