Uh oh!
There was an error while loading. Please reload this page.
[camera_avfoundation] Adds support for video stabilization - #10367
Conversation
There was a problem hiding this comment.
Code Review
This pull request adds support for video stabilization, which is a great new feature. The implementation looks solid across Dart, Swift, and Objective-C. I've found a minor issue in the Dart implementation related to a copy-paste error in a comment and a suggestion for a safer fallback value for forward compatibility. The rest of the changes, including the native implementation and tests, are well done.
| /// Returns a [ResolutionPreset]'s Pigeon representation. | ||
| PlatformVideoStabilizationMode? _pigeonVideoStabilizationMode( | ||
| VideoStabilizationMode videoStabilizationMode, | ||
| ) { | ||
| switch (videoStabilizationMode) { | ||
| case VideoStabilizationMode.off: | ||
| return PlatformVideoStabilizationMode.off; | ||
| case VideoStabilizationMode.level1: | ||
| return PlatformVideoStabilizationMode.standard; | ||
| case VideoStabilizationMode.level2: | ||
| return PlatformVideoStabilizationMode.cinematic; | ||
| case VideoStabilizationMode.level3: | ||
| return PlatformVideoStabilizationMode.cinematicExtended; | ||
| } | ||
| // The enum comes from a different package, which could get a new value at | ||
| // any time, so provide a fallback that ensures this won't break when used | ||
| // with a version that contains new values. This is deliberately outside | ||
| // the switch rather than a `default` so that the linter will flag the | ||
| // switch as needing an update. | ||
| // ignore: dead_code | ||
| return PlatformVideoStabilizationMode.cinematic; | ||
| } |
There was a problem hiding this comment.
There are a couple of improvements that can be made in this method:
- The documentation comment appears to be a copy-paste error and refers to
ResolutionPresetinstead ofVideoStabilizationMode. - The fallback return value for unknown
VideoStabilizationModevalues isPlatformVideoStabilizationMode.cinematic. It would be safer to returnnullhere. The function has a nullable return type, and the calling method_getSupportedVideoStabilizationModeMapalready handlesnullby correctly treating the mode as unsupported. This would prevent new enum values from being incorrectly mapped tocinematicmode.
/// Returns a [VideoStabilizationMode]'s Pigeon representation.PlatformVideoStabilizationMode?_pigeonVideoStabilizationMode(
VideoStabilizationMode videoStabilizationMode,
) {
switch (videoStabilizationMode) {
caseVideoStabilizationMode.off:returnPlatformVideoStabilizationMode.off;
caseVideoStabilizationMode.level1:returnPlatformVideoStabilizationMode.standard;
caseVideoStabilizationMode.level2:returnPlatformVideoStabilizationMode.cinematic;
caseVideoStabilizationMode.level3:returnPlatformVideoStabilizationMode.cinematicExtended;
}
// The enum comes from a different package, which could get a new value at// any time, so provide a fallback that ensures this won't break when used// with a version that contains new values. This is deliberately outside// the switch rather than a `default` so that the linter will flag the// switch as needing an update.// ignore: dead_codereturnnull;
}6b092c1 to
187b287Compare797cbeb to
881874fCompareLongCatIsLooong
commented
Nov 17, 2025
cc @hellohuanlin from ios triage |
d5dc938 to
cf4fa8cCompareHi, I have been updating this PR so that it is based on the latest commit in main, but I wonder if there is any point in doing so if the PR takes much longer to be reviewed. Please advise me when you're close to start the review and I'll be happy to rebase once again. |
okorohelijah
commented
Nov 24, 2025
@hellohuanlin review- from triage meeting |
68b305f to
fbe0583Compare| buildConfiguration = "Debug" | ||
| selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" | ||
| selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" | ||
| customLLDBInitFile = "$(SRCROOT)/Flutter/ephemeral/flutter_lldbinit" |
There was a problem hiding this comment.
do you know why this change is needed?
There was a problem hiding this comment.
This is a leftover after running the example project. I included this by mistake, so I will be removing it.
| completion( | ||
| FlutterError( | ||
| code: "VIDEO_STABILIZATION_ERROR", | ||
| message: "Unavailable video stabilization mode.", |
There was a problem hiding this comment.
nitpick - maybe something like
FlutterError(
code: "VIDEO_STABILIZATION_ERROR",
message: "The requested stabilization mode is not supported.",
details: [
"requested_mode": stabilizationMode.rawValue,
]
)
| /// Sets the video stabilization mode. | ||
| - (void)setVideoStabilizationMode:(FCPPlatformVideoStabilizationMode)mode | ||
| completion:(void (^)(FlutterError *_Nullable))completion; | ||
| /// Sets the video stabilization mode. |
There was a problem hiding this comment.
this should probably be like /// Gets if the video stabilization mode is supported.
| @ObjCSelector('setVideoStabilizationMode:') | ||
| void setVideoStabilizationMode(PlatformVideoStabilizationMode mode); | ||
| /// Sets the video stabilization mode. |
There was a problem hiding this comment.
this comment should be updated too :)
| @@ -1,3 +1,7 @@ | |||
| ## 0.10.0 | |||
| * Adds video stabilization. | |||
There was a problem hiding this comment.
Could you add a bit more detail? Maybe make a reference to the AVCaptureVideoStabilizationMode api you added.
There was a problem hiding this comment.
I don't know how much more detail it makes sense to add to the CHANGELOG, so I just added a mention to the 2 methods added to the Dart classes. Let me know if you need even more details.
LouiseHsu
commented
Jan 22, 2026
From triage: Are you planning to address the feedback? :) |
ruicraveiro
commented
Jan 22, 2026
Hi, yes, but I still haven't found the time. Maybe next week. |
ruicraveiro
commented
Jan 29, 2026
Hi @LouiseHsu, I just force-pushed an updated commit. It contains changes to address all your feedback. It also contains the changes needed after rebasing from the current main branch (the biggest of which was the migration of CameraProperties to swift). So, this commit also has getAvCaptureVideoStabilizationMode ported from ObjectiveC to Swift. |
635aaab to
4d9a89aCompare
hellohuanlin
left a comment
There was a problem hiding this comment.
The pigeon part may conflict with #10939
CC @RobertOdrowaz
| ) { | ||
| captureSessionQueue.async { [weak self] in | ||
| if let isSupported = self?.camera?.isVideoStabilizationModeSupported(mode) { |
There was a problem hiding this comment.
it's a bit confusing to do if let isSupported, since it's a boolean type. Can you do if let camera = ... and get isSupported from inside the if statement?
| switch videoStabilizationMode { | ||
| case .off: | ||
| return .off | ||
There was a problem hiding this comment.
nit: remove these blank lines
LouiseHsu
left a comment
There was a problem hiding this comment.
LGTM once @hellohuanlin comments have been addressed + merge conflicts.
f249f53 to
c01d1d7Compareruicraveiro
commented
Feb 10, 2026
Hi, just in case it went unnoticed, I made all the requested adjustments a few days ago. |
- Implements getSupportedVideoStabilizationModes() and setVideoStabilizationMode() methods in AVFoundationCamera.
Uh oh!
There was an error while loading. Please reload this page.
flutter/packages@af1d610...09104b0 2026-02-12 8490712+ruicraveiro@users.noreply.github.com [camera_avfoundation] Adds support for video stabilization (flutter/packages#10367) 2026-02-12 stuartmorgan@google.com [google_maps_flutter] Add README section about SDK versions (flutter/packages#11005) 2026-02-12 stuartmorgan@google.com [url_launcher] Modernize `url_launcher_ios` example (flutter/packages#11002) 2026-02-12 107683152+OlehSv@users.noreply.github.com [google_maps_flutter] Improved perfomance of clusterization (flutter/packages#10562) 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
…r#182383) flutter/packages@af1d610...09104b0 2026-02-12 8490712+ruicraveiro@users.noreply.github.com [camera_avfoundation] Adds support for video stabilization (flutter/packages#10367) 2026-02-12 stuartmorgan@google.com [google_maps_flutter] Add README section about SDK versions (flutter/packages#11005) 2026-02-12 stuartmorgan@google.com [url_launcher] Modernize `url_launcher_ios` example (flutter/packages#11002) 2026-02-12 107683152+OlehSv@users.noreply.github.com [google_maps_flutter] Improved perfomance of clusterization (flutter/packages#10562) 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
…r#182383) flutter/packages@af1d610...09104b0 2026-02-12 8490712+ruicraveiro@users.noreply.github.com [camera_avfoundation] Adds support for video stabilization (flutter/packages#10367) 2026-02-12 stuartmorgan@google.com [google_maps_flutter] Add README section about SDK versions (flutter/packages#11005) 2026-02-12 stuartmorgan@google.com [url_launcher] Modernize `url_launcher_ios` example (flutter/packages#11002) 2026-02-12 107683152+OlehSv@users.noreply.github.com [google_maps_flutter] Improved perfomance of clusterization (flutter/packages#10562) 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
…0367) Implements getSupportedVideoStabilizationModes() and setVideoStabilizationMode() methods in AVFoundationCamera. Address issue flutter/flutter#89525. It is the camera_avfoundation sub-PR for flutter#7108. ## Pre-Review Checklist **Note**: The Flutter team is currently trialing the use of [Gemini Code Assist for GitHub](https://developers.google.com/gemini-code-assist/docs/review-github-code). Comments from the `gemini-code-assist` bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed. [^1]: Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling.
Implements getSupportedVideoStabilizationModes() and setVideoStabilizationMode() methods in AVFoundationCamera.
Address issue flutter/flutter#89525.
It is the camera_avfoundation sub-PR for #7108.
Pre-Review Checklist
[shared_preferences]pubspec.yamlwith an appropriate new version according to the pub versioning philosophy, or I have commented below to indicate which version change exemption this PR falls under1.CHANGELOG.mdto add a description of the change, following repository CHANGELOG style, or I have commented below to indicate which CHANGELOG exemption this PR falls under1.///).If you need help, consider asking for advice on the #hackers-new channel on Discord.
Note: The Flutter team is currently trialing the use of Gemini Code Assist for GitHub. Comments from the
gemini-code-assistbot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed.Footnotes
Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling. ↩↩2↩3