-
Notifications
You must be signed in to change notification settings - Fork 3.3k
[camerax] Fixes unawaited_futures
violations
#4337
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
Changes from all commits
dec3d69
0e0333b
bd7ac99
5c3363b
fed9621
5aabe34
2b9a352
a1173da
cbc3d6b
cae5a4c
72283db
166a77c
399780e
8d5d0e7
ccc0715
0351c29
6b88aed
52b8faa
9d1d004
c0f6f52
3dd2855
c64b72d
8c78b95
8913126
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
## 0.5.0+8 | ||
|
||
* Fixes unawaited_futures violations. | ||
|
||
## 0.5.0+7 | ||
|
||
* Updates Guava version to 32.0.1. | ||
|
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -317,9 +317,9 @@ class AndroidCameraCameraX extends CameraPlatform { | |
@override | ||
Future<void> dispose(int cameraId) async { | ||
preview?.releaseFlutterSurfaceTexture(); | ||
liveCameraState?.removeObservers(); | ||
unawaited(liveCameraState?.removeObservers()); | ||
processCameraProvider?.unbindAll(); | ||
imageAnalysis?.clearAnalyzer(); | ||
unawaited(imageAnalysis?.clearAnalyzer()); | ||
} | ||
|
||
/// The camera has been initialized. | ||
|
@@ -423,17 +423,17 @@ class AndroidCameraCameraX extends CameraPlatform { | |
/// [cameraId] not used. | ||
@override | ||
Future<void> pausePreview(int cameraId) async { | ||
_unbindUseCaseFromLifecycle(preview!); | ||
_previewIsPaused = true; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This looks like the mistake I made in maps: you're making a field update asynchronously instead of synchronously. You probably want to reverse the statement order. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah okay yes I'll reverse the order! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was also the case in |
||
await _unbindUseCaseFromLifecycle(preview!); | ||
} | ||
|
||
/// Resume the paused preview for the selected camera. | ||
/// | ||
/// [cameraId] not used. | ||
@override | ||
Future<void> resumePreview(int cameraId) async { | ||
await _bindPreviewToLifecycle(cameraId); | ||
_previewIsPaused = false; | ||
await _bindPreviewToLifecycle(cameraId); | ||
} | ||
|
||
/// Returns a widget showing a live camera preview. | ||
|
@@ -507,7 +507,7 @@ class AndroidCameraCameraX extends CameraPlatform { | |
if (videoOutputPath == null) { | ||
// Stop the current active recording as we will be unable to complete it | ||
// in this error case. | ||
recording!.close(); | ||
unawaited(recording!.close()); | ||
recording = null; | ||
pendingRecording = null; | ||
throw CameraException( | ||
|
@@ -516,7 +516,7 @@ class AndroidCameraCameraX extends CameraPlatform { | |
'while reporting success. The platform should always ' | ||
'return a valid path or report an error.'); | ||
} | ||
recording!.close(); | ||
unawaited(recording!.close()); | ||
recording = null; | ||
pendingRecording = null; | ||
return XFile(videoOutputPath!); | ||
|
@@ -526,15 +526,15 @@ class AndroidCameraCameraX extends CameraPlatform { | |
@override | ||
Future<void> pauseVideoRecording(int cameraId) async { | ||
if (recording != null) { | ||
recording!.pause(); | ||
await recording!.pause(); | ||
} | ||
} | ||
|
||
/// Resume the current video recording if it is not null. | ||
@override | ||
Future<void> resumeVideoRecording(int cameraId) async { | ||
if (recording != null) { | ||
recording!.resume(); | ||
await recording!.resume(); | ||
} | ||
} | ||
|
||
|
@@ -614,7 +614,7 @@ class AndroidCameraCameraX extends CameraPlatform { | |
width: imageProxy.width); | ||
|
||
weakThis.target!.cameraImageDataStreamController!.add(cameraImageData); | ||
imageProxy.close(); | ||
unawaited(imageProxy.close()); | ||
} | ||
|
||
// shouldCreateDetachedObjectForTesting is used to create an Analyzer | ||
|
@@ -627,7 +627,7 @@ class AndroidCameraCameraX extends CameraPlatform { | |
// TODO(camsim99): Support resolution configuration. | ||
// Defaults to YUV_420_888 image format. | ||
imageAnalysis = createImageAnalysis(null); | ||
imageAnalysis!.setAnalyzer(analyzer); | ||
unawaited(imageAnalysis!.setAnalyzer(analyzer)); | ||
|
||
// TODO(camsim99): Reset live camera state observers here when | ||
// https://github.com/flutter/packages/pull/3419 lands. | ||
|
@@ -652,7 +652,7 @@ class AndroidCameraCameraX extends CameraPlatform { | |
/// The [onListen] callback for the stream controller used for image | ||
/// streaming. | ||
Future<void> _onFrameStreamListen() async { | ||
_configureAndBindImageAnalysisToLifecycle(); | ||
await _configureAndBindImageAnalysisToLifecycle(); | ||
} | ||
|
||
/// The [onCancel] callback for the stream controller used for image | ||
|
@@ -661,7 +661,7 @@ class AndroidCameraCameraX extends CameraPlatform { | |
/// Removes the previously set analyzer on the [imageAnalysis] instance, since | ||
/// image information should no longer be streamed. | ||
FutureOr<void> _onFrameStreamCancel() async { | ||
imageAnalysis!.clearAnalyzer(); | ||
unawaited(imageAnalysis!.clearAnalyzer()); | ||
} | ||
|
||
/// Converts between Android ImageFormat constants and [ImageFormatGroup]s. | ||
|
@@ -687,7 +687,7 @@ class AndroidCameraCameraX extends CameraPlatform { | |
/// removed, as well. | ||
Future<void> _updateLiveCameraState(int cameraId) async { | ||
final CameraInfo cameraInfo = await camera!.getCameraInfo(); | ||
liveCameraState?.removeObservers(); | ||
await liveCameraState?.removeObservers(); | ||
liveCameraState = await cameraInfo.getCameraState(); | ||
await liveCameraState!.observe(_createCameraClosingObserver(cameraId)); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bparrishMines this makes me wonder if I did some wrapping wrong. Should all of the methods I wrapped that were
void
been wrapped asFuture<void>
?