Skip to content

[camera] Add API support query for image streaming #8250

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

Merged
merged 4 commits into from
Jan 13, 2025

Conversation

liff
Copy link
Contributor

@liff liff commented Dec 9, 2024

Add API support query, supportsImageStreaming for checking if the camera platform supports image streaming.

As requested on this comment: #8234 (comment)

Attempting to follow the contribution guide wrt. changing federated plugins.

There is no issue to link to, but should I create one?

Pre-launch Checklist

If you need help, consider asking for advice on the #hackers-new channel on Discord.

Copy link
Contributor

@stuartmorgan-g stuartmorgan-g left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution!

@@ -173,6 +173,11 @@ abstract class CameraPlatform extends PlatformInterface {
throw UnimplementedError('resumeVideoRecording() is not implemented.');
}

/// Check whether this platform supports image streaming via [onStreamedFrameAvailable].
bool supportsImageStreaming() {
throw UnimplementedError('supportsImageStreaming() is not implemented.');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The default should be false, not to throw, so that existing implementations that don't support it will automatically get the right behavior.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed.

@@ -661,6 +661,9 @@ class CameraPlugin extends CameraPlatform {
);
}

@override
bool supportsImageStreaming() => false;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The web and Windows package changes won't be necessary once the base implementation is changed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed those changes.

/// The `startImageStream` method is only available on Android and iOS (other
/// platforms won't be supported in current setup).
/// The `startImageStream` method is only available on platforms that
/// report support for image streaming via [CameraPlatform.supportsImageStreaming].
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to be wrapped in a method at this layer; clients are not expected to use the platform interface directly.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a method.

Copy link
Contributor

@camsim99 camsim99 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Android changes LGTM!

@liff
Copy link
Contributor Author

liff commented Dec 10, 2024

Android build is failing in Firebase Test Lab, but I don’t seem to have permission to view the results.

@camsim99
Copy link
Contributor

Android build is failing in Firebase Test Lab, but I don’t seem to have permission to view the results.

The Android image streaming test is failing:

java.lang.Exception: ══╡ EXCEPTION CAUGHT BY FLUTTER TEST FRAMEWORK ╞═════════════════
The following assertion was thrown running a test:
'package:camera/src/camera_controller.dart': Failed assertion:
line 488 pos 12: 'supportsImageStreaming()': is not true.

When the exception was thrown, this was the stack:
#2      CameraController.startImageStream (package:camera/src/camera_controller.dart:488:12)
#3      main.<anonymous closure> (file:///b/s/w/ir/x/w/packages/packages/camera/camera/example/integration_test/camera_test.dart:251:24)
<asynchronous suspension>
#4      testWidgets.<anonymous closure>.<anonymous closure> (package:flutter_test/src/widget_tester.dart:189:15)
<asynchronous suspension>
#5      TestWidgetsFlutterBinding._runTestBody (package:flutter_test/src/binding.dart:1027:5)
<asynchronous suspension>
#6      TestWidgetsFlutterBinding._createTestCompletionHandler.<anonymous closure> (package:flutter_test/src/binding.dart:824:12)
<asynchronous suspension>
(elided 2 frames from class _AssertionError)

The test description was:
  Android image streaming
═════════════════════════════════════════════════════════════════

	at dev.flutter.plugins.integration_test.FlutterTestRunner.run(FlutterTestRunner.java:84)
	at org.junit.runners.Suite.runChild(Suite.java:128)
	at org.junit.runners.Suite.runChild(Suite.java:27)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
	at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
	at org.junit.runner.JUnitCore.run(JUnitCore.java:115)
	at androidx.test.internal.runner.TestExecutor.execute(TestExecutor.java:56)
	at androidx.test.runner.AndroidJUnitRunner.onStart(AndroidJUnitRunner.java:392)
	at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:2361)

@liff liff force-pushed the supportsImageStreaming branch 2 times, most recently from 2927697 to ead8c41 Compare December 10, 2024 19:40
@liff
Copy link
Contributor Author

liff commented Dec 11, 2024

I am unable to reproduce the failure locally with an emulator or with Firebase Test Lab.

I tried the integration tests with Firebase Test Lab both in camera/example and camera_android/example:

$ pushd android
$ ./gradlew app:assembleAndroidTest
$ ./gradlew app:assembleDebug -Ptarget=integration_test/camera_test.dart
$ popd
$ gcloud firebase test android run --type instrumentation --app build/app/outputs/apk/debug/app-debug.apk --test build/app/outputs/apk/androidTest/debug/app-debug-androidTest.apk --timeout 7m --device model=panther,version=33

But I get successful results:

camera_android

┌─────────┬────────────────────────┬─────────────────────┐
│ OUTCOME │    TEST_AXIS_VALUE     │     TEST_DETAILS    │
├─────────┼────────────────────────┼─────────────────────┤
│ Passed  │ panther-33-en-portrait │ 9 test cases passed │
└─────────┴────────────────────────┴─────────────────────┘

camera

┌─────────┬────────────────────────┬─────────────────────┐
│ OUTCOME │    TEST_AXIS_VALUE     │     TEST_DETAILS    │
├─────────┼────────────────────────┼─────────────────────┤
│ Passed  │ panther-33-en-portrait │ 4 test cases passed │
└─────────┴────────────────────────┴─────────────────────┘

and similar results with the emulator, except for this:

Failed assertion: line 89 pos 16: '!(!previousPresetExactlySupported && presetExactlySupported)'

in the “Capture specific image resolutions” test.

Any ideas as to what’s going on?

@liff
Copy link
Contributor Author

liff commented Dec 11, 2024

Re-running the check seems to have solved the problem 🎉

@liff liff force-pushed the supportsImageStreaming branch from ead8c41 to 247846d Compare December 13, 2024 07:50
Copy link
Contributor

@stuartmorgan-g stuartmorgan-g left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The API changes look good to me; this is ready to split out the first sub-PR for landing.

I left notes about missing tests, but those can be addressed in the sub PRs.

@@ -173,6 +173,9 @@ abstract class CameraPlatform extends PlatformInterface {
throw UnimplementedError('resumeVideoRecording() is not implemented.');
}

/// Check whether this platform supports image streaming via [onStreamedFrameAvailable].
bool supportsImageStreaming() => false;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will need a Dart unit test.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Included in #8307.

@liff
Copy link
Contributor Author

liff commented Dec 16, 2024

The API changes look good to me; this is ready to split out the first sub-PR for landing.

Opened the first sub-PR: #8307.

@liff liff force-pushed the supportsImageStreaming branch from 247846d to 8e65354 Compare December 16, 2024 10:09
auto-submit bot pushed a commit that referenced this pull request Jan 7, 2025
…#8307)

Add API support query, supportsImageStreaming for checking if the camera platform supports image streaming.

As requested on this comment: #8234 (comment)

Step 3 from the [changing federated plugins guide](https://github.com/flutter/flutter/blob/master/docs/ecosystem/contributing/README.md#changing-federated-plugins), split off from #8250 with a new Dart test added.
@liff liff force-pushed the supportsImageStreaming branch from 8e65354 to e32542e Compare January 8, 2025 16:37
@liff
Copy link
Contributor Author

liff commented Jan 8, 2025

Rebased on #8307.

@liff liff requested a review from stuartmorgan-g January 8, 2025 16:38
@liff liff force-pushed the supportsImageStreaming branch from e32542e to b35bf6d Compare January 13, 2025 17:40
Copy link
Contributor

@stuartmorgan-g stuartmorgan-g left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@stuartmorgan-g stuartmorgan-g added the autosubmit Merge PR when tree becomes green via auto submit App label Jan 13, 2025
@auto-submit auto-submit bot merged commit d1fd623 into flutter:main Jan 13, 2025
77 checks passed
@liff liff deleted the supportsImageStreaming branch January 13, 2025 20:36
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Jan 14, 2025
github-merge-queue bot pushed a commit to flutter/flutter that referenced this pull request Jan 14, 2025
flutter/packages@3c3bc68...d1fd623

2025-01-13 olli.helenius@codemate.com [camera] Add API support query for
image streaming (flutter/packages#8250)
2025-01-13 westracer1@gmail.com [webview_flutter_android] Add additional
WebSettings methods (flutter/packages#8270)
2025-01-13 engine-flutter-autoroll@skia.org Roll Flutter from
864d4f5 to 72db8f6 (11 revisions) (flutter/packages#8421)
2025-01-13 30872003+misos1@users.noreply.github.com
[video_player_avfoundation, camera_avfoundation] never overwrite but
only upgrade audio session category (flutter/packages#7143)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages-flutter-autoroll
Please CC flutter-ecosystem@google.com on the revert to ensure that a
human
is aware of the problem.

To file a bug in Flutter:
https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
maheshj01 pushed a commit to maheshj01/flutter that referenced this pull request Jan 15, 2025
…r#161597)

flutter/packages@3c3bc68...d1fd623

2025-01-13 olli.helenius@codemate.com [camera] Add API support query for
image streaming (flutter/packages#8250)
2025-01-13 westracer1@gmail.com [webview_flutter_android] Add additional
WebSettings methods (flutter/packages#8270)
2025-01-13 engine-flutter-autoroll@skia.org Roll Flutter from
864d4f5 to 72db8f6 (11 revisions) (flutter/packages#8421)
2025-01-13 30872003+misos1@users.noreply.github.com
[video_player_avfoundation, camera_avfoundation] never overwrite but
only upgrade audio session category (flutter/packages#7143)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages-flutter-autoroll
Please CC flutter-ecosystem@google.com on the revert to ensure that a
human
is aware of the problem.

To file a bug in Flutter:
https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
auto-submit bot pushed a commit that referenced this pull request Jan 23, 2025
Final step for introducing the `supportsImageStreaming` query method. Expose it through `CameraController`.

Previous steps:
 - #8250
 - #8307
androidseb pushed a commit to androidseb/packages that referenced this pull request Jun 8, 2025
…flutter#8307)

Add API support query, supportsImageStreaming for checking if the camera platform supports image streaming.

As requested on this comment: flutter#8234 (comment)

Step 3 from the [changing federated plugins guide](https://github.com/flutter/flutter/blob/master/docs/ecosystem/contributing/README.md#changing-federated-plugins), split off from flutter#8250 with a new Dart test added.
androidseb pushed a commit to androidseb/packages that referenced this pull request Jun 8, 2025
Add API support query, `supportsImageStreaming` for checking if the camera platform supports image streaming.

As requested on this comment: flutter#8234 (comment)

Attempting to follow the [contribution guide wrt. changing federated plugins](https://github.com/flutter/flutter/blob/master/docs/ecosystem/contributing/README.md#changing-federated-plugins).

There is no issue to link to, but should I create one?
androidseb pushed a commit to androidseb/packages that referenced this pull request Jun 8, 2025
…ter#8422)

Final step for introducing the `supportsImageStreaming` query method. Expose it through `CameraController`.

Previous steps:
 - flutter#8250
 - flutter#8307
FMorschel pushed a commit to FMorschel/packages that referenced this pull request Jun 9, 2025
…flutter#8307)

Add API support query, supportsImageStreaming for checking if the camera platform supports image streaming.

As requested on this comment: flutter#8234 (comment)

Step 3 from the [changing federated plugins guide](https://github.com/flutter/flutter/blob/master/docs/ecosystem/contributing/README.md#changing-federated-plugins), split off from flutter#8250 with a new Dart test added.
FMorschel pushed a commit to FMorschel/packages that referenced this pull request Jun 9, 2025
Add API support query, `supportsImageStreaming` for checking if the camera platform supports image streaming.

As requested on this comment: flutter#8234 (comment)

Attempting to follow the [contribution guide wrt. changing federated plugins](https://github.com/flutter/flutter/blob/master/docs/ecosystem/contributing/README.md#changing-federated-plugins).

There is no issue to link to, but should I create one?
FMorschel pushed a commit to FMorschel/packages that referenced this pull request Jun 9, 2025
…ter#8422)

Final step for introducing the `supportsImageStreaming` query method. Expose it through `CameraController`.

Previous steps:
 - flutter#8250
 - flutter#8307
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
autosubmit Merge PR when tree becomes green via auto submit App p: camera platform-android platform-ios platform-macos
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants