Skip to content

[camera_android_camerax] Force new Surface for each SurfaceRequest #9360

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

Draft
wants to merge 9 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions packages/camera/camera_android_camerax/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 0.6.19

* Ensures a new surface is provided every timethat one is requested to render the camera preview into
to fix pausing and resuming the preview.

## 0.6.18+3

* Fixes incorrect camera preview mirroring for front cameras of devices using the Impeller backend.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ public void onSurfaceCleanup() {
// Provide surface.
surfaceProducer.setSize(
request.getResolution().getWidth(), request.getResolution().getHeight());
Surface flutterSurface = surfaceProducer.getSurface();
Surface flutterSurface = surfaceProducer.getForcedNewSurface();
request.provideSurface(
flutterSurface,
Executors.newSingleThreadExecutor(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ TextureRegistry getTextureRegistry() {
ArgumentCaptor.forClass(TextureRegistry.SurfaceProducer.Callback.class);

when(mockSurfaceRequest.getResolution()).thenReturn(new Size(5, 6));
when(mockSurfaceProducer.getSurface()).thenReturn(mock(Surface.class));
when(mockSurfaceProducer.getForcedNewSurface()).thenReturn(mock(Surface.class));

final Preview.SurfaceProvider previewSurfaceProvider =
api.createSurfaceProvider(mockSurfaceProducer, mockSystemServicesManager);
Expand Down Expand Up @@ -155,7 +155,7 @@ TextureRegistry getTextureRegistry() {

when(mockSurfaceRequest.getResolution())
.thenReturn(new Size(resolutionWidth, resolutionHeight));
when(mockSurfaceProducer.getSurface()).thenReturn(mockSurface);
when(mockSurfaceProducer.getForcedNewSurface()).thenReturn(mockSurface);

final ArgumentCaptor<Surface> surfaceCaptor = ArgumentCaptor.forClass(Surface.class);
final ArgumentCaptor<Consumer<SurfaceRequest.Result>> consumerCaptor =
Expand Down
2 changes: 1 addition & 1 deletion packages/camera/camera_android_camerax/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: camera_android_camerax
description: Android implementation of the camera plugin using the CameraX library.
repository: https://github.com/flutter/packages/tree/main/packages/camera/camera_android_camerax
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+camera%22
version: 0.6.18+3
version: 0.6.19

environment:
sdk: ^3.7.0
Expand Down