-
Notifications
You must be signed in to change notification settings - Fork 3k
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
[camera_windows] Support image streams on Windows platform #7067
Conversation
It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact "@test-exemption-reviewer" in the #hackers channel in Chat (don't just cc them here, they won't see it! Use Discord!). If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix? Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
Taking a look, but before I do, looks like some small Dart analysis errors:
|
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.
Thanks for your PR! A few first-round comments.
Looks like the camera windows implementation was just switched to pigeon, unfortunate timing but I'll migrate the changes across |
Ugh yeah was just thinking about that as I reviewed the other one. On the plus side, the code should be significantly simpler, but frustrating to deal with the merge. |
# Conflicts: # packages/camera/camera_windows/lib/camera_windows.dart # packages/camera/camera_windows/windows/camera_plugin.cpp # packages/camera/camera_windows/windows/camera_plugin.h
I think i have worked out how to replace the method channels, just unsure if i still need the frame event channel. flutter/flutter#66711 seems to indicate that pigeon doesn't use an event channel under the hood so I'm assuming its less performant for this use case? |
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.
LGTM to the camera
change. I will leave the windows review to @cbracken and will approve on version bumps.
I tested this as working :) using @jlundOverlay's fork until this is merged, thanks! |
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.
I have made a new PR for the camera version bump #7220 |
@jlundOverlay Ideally we should have tests for this change. What do you think of updating |
Took me a bit to work out how to mock the EventSink but i think i got there in the end. let me know what you think. |
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.
Looks great! Excellent work!
"Unable to make event channel from windows")); | ||
} | ||
|
||
if (camera->AddPendingVoidResult(PendingResultType::kStartStream, |
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.
Where are the pending results added in this PR resolved? I don't see anything in the diff that retrieves them.
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.
good question, when i wrote it figured id deal with that later and forgot. What exactly are these checks used for and are they necessary if the function is synchronous?
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.
There will be no result object if the API is made synchronous.
@@ -70,6 +70,14 @@ abstract class CameraApi { | |||
@async | |||
String stopVideoRecording(int cameraId); | |||
|
|||
/// Starts the image stream for the given camera. | |||
@async |
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.
Why are these @async
? It looks like the logic is synchronous.
flutter/packages@3d358d9...247fb5f 2024-07-29 49699333+dependabot[bot]@users.noreply.github.com [image_picker]: Bump androidx.activity:activity from 1.9.0 to 1.9.1 in /packages/image_picker/image_picker_android/android (flutter/packages#7245) 2024-07-29 49699333+dependabot[bot]@users.noreply.github.com [in_app_pur]: Bump androidx.annotation:annotation from 1.8.0 to 1.8.1 in /packages/in_app_purchase/in_app_purchase_android/android (flutter/packages#7239) 2024-07-29 49699333+dependabot[bot]@users.noreply.github.com [image_picker]: Bump androidx.annotation:annotation from 1.7.1 to 1.8.0 in /packages/image_picker/image_picker_android/android (flutter/packages#6763) 2024-07-29 49699333+dependabot[bot]@users.noreply.github.com [file_selector]: Bump androidx.annotation:annotation from 1.8.0 to 1.8.1 in /packages/file_selector/file_selector_android/android (flutter/packages#7240) 2024-07-29 49699333+dependabot[bot]@users.noreply.github.com [url_launcher]: Bump androidx.annotation:annotation from 1.8.0 to 1.8.1 in /packages/url_launcher/url_launcher_android/android (flutter/packages#7243) 2024-07-29 49699333+dependabot[bot]@users.noreply.github.com Bump github/codeql-action from 3.25.12 to 3.25.15 (flutter/packages#7235) 2024-07-29 [email protected] Roll Flutter from 7d5c1c0 to 031dc3d (97 revisions) (flutter/packages#7225) 2024-07-26 [email protected] [camera_windows] Support image streams on Windows platform (flutter/packages#7067) 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 [email protected],[email protected] 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
flutter/packages@3d358d9...247fb5f 2024-07-29 49699333+dependabot[bot]@users.noreply.github.com [image_picker]: Bump androidx.activity:activity from 1.9.0 to 1.9.1 in /packages/image_picker/image_picker_android/android (flutter/packages#7245) 2024-07-29 49699333+dependabot[bot]@users.noreply.github.com [in_app_pur]: Bump androidx.annotation:annotation from 1.8.0 to 1.8.1 in /packages/in_app_purchase/in_app_purchase_android/android (flutter/packages#7239) 2024-07-29 49699333+dependabot[bot]@users.noreply.github.com [image_picker]: Bump androidx.annotation:annotation from 1.7.1 to 1.8.0 in /packages/image_picker/image_picker_android/android (flutter/packages#6763) 2024-07-29 49699333+dependabot[bot]@users.noreply.github.com [file_selector]: Bump androidx.annotation:annotation from 1.8.0 to 1.8.1 in /packages/file_selector/file_selector_android/android (flutter/packages#7240) 2024-07-29 49699333+dependabot[bot]@users.noreply.github.com [url_launcher]: Bump androidx.annotation:annotation from 1.8.0 to 1.8.1 in /packages/url_launcher/url_launcher_android/android (flutter/packages#7243) 2024-07-29 49699333+dependabot[bot]@users.noreply.github.com Bump github/codeql-action from 3.25.12 to 3.25.15 (flutter/packages#7235) 2024-07-29 [email protected] Roll Flutter from 7d5c1c0 to 031dc3d (97 revisions) (flutter/packages#7225) 2024-07-26 [email protected] [camera_windows] Support image streams on Windows platform (flutter/packages#7067) 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 [email protected],[email protected] 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
flutter/packages@3d358d9...247fb5f 2024-07-29 49699333+dependabot[bot]@users.noreply.github.com [image_picker]: Bump androidx.activity:activity from 1.9.0 to 1.9.1 in /packages/image_picker/image_picker_android/android (flutter/packages#7245) 2024-07-29 49699333+dependabot[bot]@users.noreply.github.com [in_app_pur]: Bump androidx.annotation:annotation from 1.8.0 to 1.8.1 in /packages/in_app_purchase/in_app_purchase_android/android (flutter/packages#7239) 2024-07-29 49699333+dependabot[bot]@users.noreply.github.com [image_picker]: Bump androidx.annotation:annotation from 1.7.1 to 1.8.0 in /packages/image_picker/image_picker_android/android (flutter/packages#6763) 2024-07-29 49699333+dependabot[bot]@users.noreply.github.com [file_selector]: Bump androidx.annotation:annotation from 1.8.0 to 1.8.1 in /packages/file_selector/file_selector_android/android (flutter/packages#7240) 2024-07-29 49699333+dependabot[bot]@users.noreply.github.com [url_launcher]: Bump androidx.annotation:annotation from 1.8.0 to 1.8.1 in /packages/url_launcher/url_launcher_android/android (flutter/packages#7243) 2024-07-29 49699333+dependabot[bot]@users.noreply.github.com Bump github/codeql-action from 3.25.12 to 3.25.15 (flutter/packages#7235) 2024-07-29 [email protected] Roll Flutter from 7d5c1c0 to 031dc3d (97 revisions) (flutter/packages#7225) 2024-07-26 [email protected] [camera_windows] Support image streams on Windows platform (flutter/packages#7067) 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 [email protected],[email protected] 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
This comment was marked as off-topic.
This comment was marked as off-topic.
return nullptr; | ||
}, | ||
[](auto arguments) { | ||
event_sink.reset(); |
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.
I was going to do a quick fix to the issues I raised in my previous comments, but then I noticed the code related to event_sink
. This is a global, which is already very dangerous, but it's also std::move
d between classes while still being referenced persistently in both. This code would likely fail the second time an image stream was started, and would absolutely fail with multiple engines.
Given the scope of issues here, I'm going to revert this. @cbracken FYI.
…7951) This reverts commit b31a279 (#7067) The implementation had significant bugs: - It had asynchronous results, but never responded to them, violating the engine API contract and preventing futures from completing. - It `std::move`d pointers between classes, while still keeping them as ivars and global references and referring to them from long-lived handlers.
The logic is synchronous, so there is no need to have the `@async` annotation here. Addresses: flutter#7067 (comment)
Instead of a global `EventSink` that is re-used for each stream, create a dedicated `EventChannel` for each capture stream. The channel gets an unique name like `plugins.flutter.io/camera_android/imageStream/<cameraId>` for each camera instance. Addresses: flutter#7067 (comment)
The logic is synchronous, so there is no need to have the `@async` annotation here. Addresses: flutter#7067 (comment)
Instead of a global `EventSink` that is re-used for each stream, create a dedicated `EventChannel` for each capture stream. The channel gets an unique name like `plugins.flutter.io/camera_android/imageStream/<cameraId>` for each camera instance. Addresses: flutter#7067 (comment)
Adds support to the windows camera implementation to allow streaming of frames.
Fixes flutter/flutter#97542
Pre-launch Checklist
dart format
.)[shared_preferences]
pubspec.yaml
with an appropriate new version according to the [pub versioning philosophy], or this PR is [exempt from version changes].CHANGELOG.md
to add a description of the change, [following repository CHANGELOG style], or this PR is [exempt from CHANGELOG changes].///
).If you need help, consider asking for advice on the #hackers-new channel on [Discord].