Skip to content

Conversation

@js2702
Copy link
Contributor

@js2702 js2702 commented Feb 27, 2025

Fixes flutter/flutter#147702

It's not easy to reproduce this with the example application (as shown in the linked issue). We've been able to reproduce it in our own application which makes heavy usage of Platform channels and different native plugins. After digging into the code we notice that:

The Dart code that starts listening to the event channel was being executed before initializing the stream in the native side.

I don't have much experience with Objective-C, so not sure how to create unit tests for that if necessary but I believe this would be an adecuate solution. I've seen other methods in the plugin that use the same strategy passing the completion object.

Pre-launch Checklist

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

@js2702 js2702 requested a review from hellohuanlin as a code owner February 27, 2025 17:24
@flutter-dashboard
Copy link

It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption, contact "@test-exemption-reviewer" in the #hackers channel in Discord (don't just cc them here, they won't see it!).

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. The test exemption team is a small volunteer group, so all reviewers should feel empowered to ask for tests, without delegating that responsibility entirely to the test exemption group.

@google-cla
Copy link

google-cla bot commented Feb 27, 2025

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@js2702 js2702 force-pushed the fix_startstream_race_condition branch from 89cc825 to e902881 Compare February 27, 2025 17:37
@js2702
Copy link
Contributor Author

js2702 commented Feb 27, 2025

I'm not sure why but I'm getting a 400 error when signing the CLA (Which I thought I had already signed for other PR)

@hellohuanlin
Copy link
Contributor

This will require unit test in order to land.

@js2702
Copy link
Contributor Author

js2702 commented Feb 27, 2025

I'm looking for any example test but I don't see anything. As this doesn't affect the Dart part I don't see how to make a test for this, wouldn't this be test exempt?

Additionally, this bug in particular manifests as a race condition in the communication with Dart and native, requiring an end to end test, which I'm not seeing either.

@stuartmorgan-g
Copy link
Collaborator

stuartmorgan-g commented Feb 27, 2025

As this doesn't affect the Dart part I don't see how to make a test for this, wouldn't this be test exempt?

There is no blanket test exemption for native code; if there were, almost nothing in plugins would be tested. Please see https://github.com/flutter/flutter/blob/master/docs/ecosystem/testing/Plugin-Tests.md

js2702 added 3 commits March 1, 2025 15:06
# Conflicts:
#	packages/camera/camera_avfoundation/example/ios/Runner.xcodeproj/project.pbxproj
#	packages/camera/camera_avfoundation/example/ios/RunnerTests/StreamingTest.m
@js2702
Copy link
Contributor Author

js2702 commented Mar 2, 2025

I added a test for the issue. Everything was working before this last Swift refactor. A few things:

  1. Now these tests that were just changed in StreamingTests.swift (I did not change this file in the PR, as I'm not sure why this is needed now) fail because they are not async/await. Not sure why this happens as I don't see anything that would need async. These are the calls that fail:

https://github.com/SkillDevs/flutter_packages/blob/423c038bdb06ee8d75a2e6523e1ce688e0b555a0/packages/camera/camera_avfoundation/example/ios/RunnerTests/StreamingTests.swift#L74

  1. In my tests, I'm not sure if there is a better way to expect the streamHandler is initialized instead of checking the boolean flag.
  2. Also, in this completion call
    https://github.com/SkillDevs/flutter_packages/blob/423c038bdb06ee8d75a2e6523e1ce688e0b555a0/packages/camera/camera_avfoundation/ios/camera_avfoundation/Sources/camera_avfoundation/FLTCam.m#L1206
    Should the completion be at the beginning, on each early return, or it's fine where it is?

Again, not an expert in Swift/Objective-C.

Also, the test was developed in Master and it failed unless you added a delay before the expect.

@js2702
Copy link
Contributor Author

js2702 commented Mar 2, 2025

Ended up adding the async/await because the tests pass with that, I guess it's because of the callback added to the function?

@hellohuanlin
Copy link
Contributor

Ended up adding the async/await because the tests pass with that, I guess it's because of the callback added to the function?

The async/await api is generated. Can you use completion callbacks to be consistent with other tests?

js2702 added 2 commits March 5, 2025 13:04
…ondition

# Conflicts:
#	packages/camera/camera_avfoundation/CHANGELOG.md
@js2702
Copy link
Contributor Author

js2702 commented Mar 5, 2025

@hellohuanlin I updated the tests to use the completion callback, I had to move the expectation creation step of the streaming test because the existing expectation only were run when actually capturing output.

@js2702
Copy link
Contributor Author

js2702 commented Mar 6, 2025

@hellohuanlin I don't even know what is happening with the formating checks in CI, it keeps flipping between:

-extern const char *FLTCaptureSessionQueueSpecific;
+extern const char* FLTCaptureSessionQueueSpecific;

If I make the change the CI will apply the other formatting.

@stuartmorgan-g
Copy link
Collaborator

@hellohuanlin I don't even know what is happening with the formating checks in CI, it keeps flipping between:

-extern const char *FLTCaptureSessionQueueSpecific;
+extern const char* FLTCaptureSessionQueueSpecific;

If I make the change the CI will apply the other formatting.

I think you're conflating the output for two different files: QueueUtils.m, and QueueUtils.h. I see consistent CI output across each file for the last three runs. The formatting between the files isn't consistent, but that's just a quirk of the header not being identified by clang-format as Obj-C rather than C, and our pointer alignment rules are different for Obj-C.

@js2702
Copy link
Contributor Author

js2702 commented Mar 6, 2025

@stuartmorgan Thank you but I'm not sure I'm following, what would be the fix? I'm running the provided format command and it doesn't change anything in the current state of the PR.

This is the output

❯ dart run script/tool/bin/flutter_plugin_tools.dart format --packages camera_avfoundation
Formatting .cc, .cpp, .h, .m, and .mm files...
Running command: "clang-format -i --style=file camera/camera_avfoundation/example/ios/Runner/AppDelegate.h camera/camera_avfoundation/example/ios/Runner/AppDelegate.m camera/camera_avfoundation/example/ios/Runner/GeneratedPluginRegistrant.h camera/camera_avfoundation/example/ios/Runner/GeneratedPluginRegistrant.m camera/camera_avfoundation/example/ios/Runner/main.m camera/camera_avfoundation/example/ios/RunnerTests/CameraTestUtils.h camera/camera_avfoundation/example/ios/RunnerTests/CameraTestUtils.m camera/camera_avfoundation/example/ios/RunnerTests/CameraUtilTests.m camera/camera_avfoundation/example/ios/RunnerTests/ExceptionCatcher.h camera/camera_avfoundation/example/ios/RunnerTests/ExceptionCatcher.m camera/camera_avfoundation/example/ios/RunnerTests/Mocks/MockAssetWriter.h camera/camera_avfoundation/example/ios/RunnerTests/Mocks/MockAssetWriter.m camera/camera_avfoundation/example/ios/RunnerTests/Mocks/MockCameraDeviceDiscoverer.h camera/camera_avfoundation/example/ios/RunnerTests/Mocks/MockCameraDeviceDiscoverer.m camera/camera_avfoundation/example/ios/RunnerTests/Mocks/MockCaptureConnection.h camera/camera_avfoundation/example/ios/RunnerTests/Mocks/MockCaptureConnection.m camera/camera_avfoundation/example/ios/RunnerTests/Mocks/MockCaptureDevice.h camera/camera_avfoundation/example/ios/RunnerTests/Mocks/MockCaptureDevice.m camera/camera_avfoundation/example/ios/RunnerTests/Mocks/MockCaptureDeviceFormat.h camera/camera_avfoundation/example/ios/RunnerTests/Mocks/MockCaptureDeviceFormat.m camera/camera_avfoundation/example/ios/RunnerTests/Mocks/MockCapturePhotoOutput.h camera/camera_avfoundation/example/ios/RunnerTests/Mocks/MockCapturePhotoOutput.m camera/camera_avfoundation/example/ios/RunnerTests/Mocks/MockCaptureSession.h camera/camera_avfoundation/example/ios/RunnerTests/Mocks/MockCaptureSession.m camera/camera_avfoundation/example/ios/RunnerTests/Mocks/MockDeviceOrientationProvider.h camera/camera_avfoundation/example/ios/RunnerTests/Mocks/MockDeviceOrientationProvider.m camera/camera_avfoundation/example/ios/RunnerTests/Mocks/MockFlutterBinaryMessenger.h camera/camera_avfoundation/example/ios/RunnerTests/Mocks/MockFlutterBinaryMessenger.m camera/camera_avfoundation/example/ios/RunnerTests/Mocks/MockFlutterTextureRegistry.h camera/camera_avfoundation/example/ios/RunnerTests/Mocks/MockFlutterTextureRegistry.m camera/camera_avfoundation/example/ios/RunnerTests/Mocks/MockGlobalEventApi.h camera/camera_avfoundation/example/ios/RunnerTests/Mocks/MockGlobalEventApi.m camera/camera_avfoundation/example/ios/RunnerTests/RunnerTests-Bridging-Header.h camera/camera_avfoundation/ios/camera_avfoundation/Sources/camera_avfoundation/CameraPlugin.m camera/camera_avfoundation/ios/camera_avfoundation/Sources/camera_avfoundation/CameraProperties.m camera/camera_avfoundation/ios/camera_avfoundation/Sources/camera_avfoundation/FLTAssetWriter.m camera/camera_avfoundation/ios/camera_avfoundation/Sources/camera_avfoundation/FLTCam.m camera/camera_avfoundation/ios/camera_avfoundation/Sources/camera_avfoundation/FLTCamConfiguration.m camera/camera_avfoundation/ios/camera_avfoundation/Sources/camera_avfoundation/FLTCamMediaSettingsAVWrapper.m camera/camera_avfoundation/ios/camera_avfoundation/Sources/camera_avfoundation/FLTCameraDeviceDiscovering.m camera/camera_avfoundation/ios/camera_avfoundation/Sources/camera_avfoundation/FLTCameraPermissionManager.m camera/camera_avfoundation/ios/camera_avfoundation/Sources/camera_avfoundation/FLTCaptureConnection.m camera/camera_avfoundation/ios/camera_avfoundation/Sources/camera_avfoundation/FLTCaptureDevice.m camera/camera_avfoundation/ios/camera_avfoundation/Sources/camera_avfoundation/FLTCaptureDeviceFormat.m camera/camera_avfoundation/ios/camera_avfoundation/Sources/camera_avfoundation/FLTCapturePhotoOutput.m camera/camera_avfoundation/ios/camera_avfoundation/Sources/camera_avfoundation/FLTCaptureSession.m camera/camera_avfoundation/ios/camera_avfoundation/Sources/camera_avfoundation/FLTDeviceOrientationProviding.m camera/camera_avfoundation/ios/camera_avfoundation/Sources/camera_avfoundation/FLTPermissionServicing.m camera/camera_avfoundation/ios/camera_avfoundation/Sources/camera_avfoundation/FLTSavePhotoDelegate.m camera/camera_avfoundation/ios/camera_avfoundation/Sources/camera_avfoundation/FLTThreadSafeEventChannel.m camera/camera_avfoundation/ios/camera_avfoundation/Sources/camera_avfoundation/FLTWritableData.m camera/camera_avfoundation/ios/camera_avfoundation/Sources/camera_avfoundation/QueueUtils.m camera/camera_avfoundation/ios/camera_avfoundation/Sources/camera_avfoundation/include/camera_avfoundation-umbrella.h camera/camera_avfoundation/ios/camera_avfoundation/Sources/camera_avfoundation/include/camera_avfoundation/CameraPlugin.h camera/camera_avfoundation/ios/camera_avfoundation/Sources/camera_avfoundation/include/camera_avfoundation/CameraPlugin_Test.h camera/camera_avfoundation/ios/camera_avfoundation/Sources/camera_avfoundation/include/camera_avfoundation/CameraProperties.h camera/camera_avfoundation/ios/camera_avfoundation/Sources/camera_avfoundation/include/camera_avfoundation/FLTAssetWriter.h camera/camera_avfoundation/ios/camera_avfoundation/Sources/camera_avfoundation/include/camera_avfoundation/FLTCam.h camera/camera_avfoundation/ios/camera_avfoundation/Sources/camera_avfoundation/include/camera_avfoundation/FLTCamConfiguration.h camera/camera_avfoundation/ios/camera_avfoundation/Sources/camera_avfoundation/include/camera_avfoundation/FLTCamMediaSettingsAVWrapper.h camera/camera_avfoundation/ios/camera_avfoundation/Sources/camera_avfoundation/include/camera_avfoundation/FLTCam_Test.h camera/camera_avfoundation/ios/camera_avfoundation/Sources/camera_avfoundation/include/camera_avfoundation/FLTCameraDeviceDiscovering.h camera/camera_avfoundation/ios/camera_avfoundation/Sources/camera_avfoundation/include/camera_avfoundation/FLTCameraPermissionManager.h camera/camera_avfoundation/ios/camera_avfoundation/Sources/camera_avfoundation/include/camera_avfoundation/FLTCaptureConnection.h camera/camera_avfoundation/ios/camera_avfoundation/Sources/camera_avfoundation/include/camera_avfoundation/FLTCaptureDevice.h camera/camera_avfoundation/ios/camera_avfoundation/Sources/camera_avfoundation/include/camera_avfoundation/FLTCaptureDeviceFormat.h camera/camera_avfoundation/ios/camera_avfoundation/Sources/camera_avfoundation/include/camera_avfoundation/FLTCapturePhotoOutput.h camera/camera_avfoundation/ios/camera_avfoundation/Sources/camera_avfoundation/include/camera_avfoundation/FLTCaptureSession.h camera/camera_avfoundation/ios/camera_avfoundation/Sources/camera_avfoundation/include/camera_avfoundation/FLTDeviceOrientationProviding.h camera/camera_avfoundation/ios/camera_avfoundation/Sources/camera_avfoundation/include/camera_avfoundation/FLTEventChannel.h camera/camera_avfoundation/ios/camera_avfoundation/Sources/camera_avfoundation/include/camera_avfoundation/FLTPermissionServicing.h camera/camera_avfoundation/ios/camera_avfoundation/Sources/camera_avfoundation/include/camera_avfoundation/FLTSavePhotoDelegate.h camera/camera_avfoundation/ios/camera_avfoundation/Sources/camera_avfoundation/include/camera_avfoundation/FLTSavePhotoDelegate_Test.h camera/camera_avfoundation/ios/camera_avfoundation/Sources/camera_avfoundation/include/camera_avfoundation/FLTThreadSafeEventChannel.h camera/camera_avfoundation/ios/camera_avfoundation/Sources/camera_avfoundation/include/camera_avfoundation/FLTWritableData.h camera/camera_avfoundation/ios/camera_avfoundation/Sources/camera_avfoundation/include/camera_avfoundation/QueueUtils.h camera/camera_avfoundation/ios/camera_avfoundation/Sources/camera_avfoundation/include/camera_avfoundation/messages.g.h camera/camera_avfoundation/ios/camera_avfoundation/Sources/camera_avfoundation/messages.g.m" in /Users/jorge/Developer/packages/packages
Formatting .swift files...
Running command: "swift-format -i camera/camera_avfoundation/example/ios/Flutter/ephemeral/Packages/FlutterGeneratedPluginSwiftPackage/Package.swift camera/camera_avfoundation/example/ios/Flutter/ephemeral/Packages/FlutterGeneratedPluginSwiftPackage/Sources/FlutterGeneratedPluginSwiftPackage/FlutterGeneratedPluginSwiftPackage.swift camera/camera_avfoundation/example/ios/RunnerTests/AvailableCamerasTests.swift camera/camera_avfoundation/example/ios/RunnerTests/CameraExposureTests.swift camera/camera_avfoundation/example/ios/RunnerTests/CameraFocusTests.swift camera/camera_avfoundation/example/ios/RunnerTests/CameraInitRaceConditionsTests.swift camera/camera_avfoundation/example/ios/RunnerTests/CameraMethodChannelTests.swift camera/camera_avfoundation/example/ios/RunnerTests/CameraOrientationTests.swift camera/camera_avfoundation/example/ios/RunnerTests/CameraPermissionTests.swift camera/camera_avfoundation/example/ios/RunnerTests/CameraPluginCreateCameraTests.swift camera/camera_avfoundation/example/ios/RunnerTests/CameraPluginInitializeCameraTests.swift camera/camera_avfoundation/example/ios/RunnerTests/CameraPreviewPauseTests.swift camera/camera_avfoundation/example/ios/RunnerTests/CameraPropertiesTests.swift camera/camera_avfoundation/example/ios/RunnerTests/CameraSessionPresetsTests.swift camera/camera_avfoundation/example/ios/RunnerTests/CameraSettingsTests.swift camera/camera_avfoundation/example/ios/RunnerTests/Mocks/MockEventChannel.swift camera/camera_avfoundation/example/ios/RunnerTests/Mocks/MockFLTCam.swift camera/camera_avfoundation/example/ios/RunnerTests/Mocks/MockFLTCameraPermissionManager.swift camera/camera_avfoundation/example/ios/RunnerTests/Mocks/MockWritableData.swift camera/camera_avfoundation/example/ios/RunnerTests/PhotoCaptureTests.swift camera/camera_avfoundation/example/ios/RunnerTests/QueueUtilsTests.swift camera/camera_avfoundation/example/ios/RunnerTests/SampleBufferTests.swift camera/camera_avfoundation/example/ios/RunnerTests/SavePhotoDelegateTests.swift camera/camera_avfoundation/example/ios/RunnerTests/StreamingTests.swift camera/camera_avfoundation/example/ios/RunnerTests/ThreadSafeEventChannelTests.swift camera/camera_avfoundation/ios/camera_avfoundation/Package.swift" in /Users/jorge/Developer/packages/packages
Linting .swift files...
Running command: "swift-format lint --parallel --strict camera/camera_avfoundation/example/ios/Flutter/ephemeral/Packages/FlutterGeneratedPluginSwiftPackage/Package.swift camera/camera_avfoundation/example/ios/Flutter/ephemeral/Packages/FlutterGeneratedPluginSwiftPackage/Sources/FlutterGeneratedPluginSwiftPackage/FlutterGeneratedPluginSwiftPackage.swift camera/camera_avfoundation/example/ios/RunnerTests/AvailableCamerasTests.swift camera/camera_avfoundation/example/ios/RunnerTests/CameraExposureTests.swift camera/camera_avfoundation/example/ios/RunnerTests/CameraFocusTests.swift camera/camera_avfoundation/example/ios/RunnerTests/CameraInitRaceConditionsTests.swift camera/camera_avfoundation/example/ios/RunnerTests/CameraMethodChannelTests.swift camera/camera_avfoundation/example/ios/RunnerTests/CameraOrientationTests.swift camera/camera_avfoundation/example/ios/RunnerTests/CameraPermissionTests.swift camera/camera_avfoundation/example/ios/RunnerTests/CameraPluginCreateCameraTests.swift camera/camera_avfoundation/example/ios/RunnerTests/CameraPluginInitializeCameraTests.swift camera/camera_avfoundation/example/ios/RunnerTests/CameraPreviewPauseTests.swift camera/camera_avfoundation/example/ios/RunnerTests/CameraPropertiesTests.swift camera/camera_avfoundation/example/ios/RunnerTests/CameraSessionPresetsTests.swift camera/camera_avfoundation/example/ios/RunnerTests/CameraSettingsTests.swift camera/camera_avfoundation/example/ios/RunnerTests/Mocks/MockEventChannel.swift camera/camera_avfoundation/example/ios/RunnerTests/Mocks/MockFLTCam.swift camera/camera_avfoundation/example/ios/RunnerTests/Mocks/MockFLTCameraPermissionManager.swift camera/camera_avfoundation/example/ios/RunnerTests/Mocks/MockWritableData.swift camera/camera_avfoundation/example/ios/RunnerTests/PhotoCaptureTests.swift camera/camera_avfoundation/example/ios/RunnerTests/QueueUtilsTests.swift camera/camera_avfoundation/example/ios/RunnerTests/SampleBufferTests.swift camera/camera_avfoundation/example/ios/RunnerTests/SavePhotoDelegateTests.swift camera/camera_avfoundation/example/ios/RunnerTests/StreamingTests.swift camera/camera_avfoundation/example/ios/RunnerTests/ThreadSafeEventChannelTests.swift camera/camera_avfoundation/ios/camera_avfoundation/Package.swift" in /Users/jorge/Developer/packages/packages

============================================================
|| Running for packages/camera/camera_avfoundation
============================================================

Formatting .dart files...
Running command: "dart format example/integration_test/camera_test.dart example/lib/camera_controller.dart example/lib/camera_preview.dart example/lib/main.dart example/test_driver/integration_test.dart lib/camera_avfoundation.dart lib/src/avfoundation_camera.dart lib/src/messages.g.dart lib/src/type_conversion.dart lib/src/utils.dart pigeons/messages.dart test/avfoundation_camera_test.dart test/avfoundation_camera_test.mocks.dart test/flutter_test_config.dart test/type_conversion_test.dart test/utils_test.dart" in /Users/jorge/Developer/packages/packages/camera/camera_avfoundation
Formatted 16 files (0 changed) in 0.39 seconds.


------------------------------------------------------------
Run overview:
  packages/camera/camera_avfoundation - ran

Ran for 1 package(s)


No issues found!

# Conflicts:
#	packages/camera/camera_avfoundation/CHANGELOG.md
#	packages/camera/camera_avfoundation/example/ios/RunnerTests/CameraInitRaceConditionsTests.swift
@js2702 js2702 requested a review from vashworth as a code owner April 29, 2025 10:56
chaosue pushed a commit to chaosue/flutter_packages that referenced this pull request May 28, 2025
Copy link
Collaborator

@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.

Sorry, I missed the notification that this was ready for review again and it fell off my radar. Overall it looks good, just some minor issues.

Copy link
Collaborator

@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.

Fixing status; that was meant to be a request-changes comment.

Also, this will need a merge with main, since we can't trigger that from our end since the branch doesn't allow Flutter team members to push to it.

js2702 added 4 commits June 13, 2025 12:42
…condition

# Conflicts:
#	packages/camera/camera_avfoundation/CHANGELOG.md
#	packages/camera/camera_avfoundation/example/ios/RunnerTests/CameraInitRaceConditionsTests.swift
#	packages/camera/camera_avfoundation/example/ios/RunnerTests/Mocks/MockCamera.swift
#	packages/camera/camera_avfoundation/example/ios/RunnerTests/StreamingTests.swift
#	packages/camera/camera_avfoundation/ios/camera_avfoundation/Sources/camera_avfoundation_objc/CameraPlugin.m
#	packages/camera/camera_avfoundation/ios/camera_avfoundation/Sources/camera_avfoundation_objc/FLTCam.m
#	packages/camera/camera_avfoundation/ios/camera_avfoundation/Sources/camera_avfoundation_objc/include/camera_avfoundation/FLTCam_Test.h
#	packages/camera/camera_avfoundation/pubspec.yaml
Copy link
Collaborator

@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, that's much easier to follow! One nit, and one logic issue that I noticed due to the new diff, and then this will be good to land.

@js2702 js2702 requested a review from stuartmorgan-g June 13, 2025 17:26
Copy link
Collaborator

@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, thanks!

attributes:nil
error:&error];
if (error) {
BOOL success = [[NSFileManager defaultManager] createDirectoryAtPath:fileDir
Copy link
Collaborator

Choose a reason for hiding this comment

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

Good catch on this change!

@stuartmorgan-g stuartmorgan-g added the autosubmit Merge PR when tree becomes green via auto submit App label Jun 16, 2025
@auto-submit
Copy link
Contributor

auto-submit bot commented Jun 16, 2025

autosubmit label was removed for flutter/packages/8733, because - The status or check suite Linux_android_legacy android_platform_tests_legacy_api_shard_1 master has failed. Please fix the issues identified (or deflake) before re-applying this label.

@auto-submit auto-submit bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Jun 16, 2025
@js2702
Copy link
Contributor Author

js2702 commented Jun 16, 2025

@stuartmorgan-g The autosubmit label was removed because of a flaky job, can you guys retry individual jobs or should I keep commiting until it passes?

@stuartmorgan-g stuartmorgan-g added the autosubmit Merge PR when tree becomes green via auto submit App label Jun 16, 2025
@auto-submit auto-submit bot merged commit 6d057de into flutter:main Jun 16, 2025
78 checks passed
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Jun 17, 2025
github-merge-queue bot pushed a commit to flutter/flutter that referenced this pull request Jun 17, 2025
flutter/packages@03a6abb...25d4fa4

2025-06-17 22373191+Hari-07@users.noreply.github.com
[google_maps_flutter] Add a new zIndexInt param to marker and deprecate
zIndex (flutter/packages#8012)
2025-06-17 33691143+JesseRiemens@users.noreply.github.com [pigeon] Use a
const for custom type ids for gobject generated files (#156100)
(flutter/packages#9306)
2025-06-16 22373191+Hari-07@users.noreply.github.com
[google_maps_flutter_platform_(web/android/ios)] Add a new zIndexInt
param to marker and deprecate zIndex (flutter/packages#9408)
2025-06-16 jorgesarpe@gmail.com [camera_avfoundation] fix race condition
when starting image stream on iOS (flutter/packages#8733)
2025-06-16 engine-flutter-autoroll@skia.org Roll Flutter from
f79452e to 8303a96 (21 revisions) (flutter/packages#9433)

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
Ortes pushed a commit to Ortes/packages that referenced this pull request Jun 25, 2025
…n iOS (flutter#8733)

Fixes flutter/flutter#147702 

It's not easy to reproduce this with the example application (as shown in the linked issue). We've been able to reproduce it in our own application which makes heavy usage of Platform channels and different native plugins. After digging into the code we notice that:

The Dart code that starts listening to the event channel was being executed before initializing the stream in the native side. 

https://github.com/flutter/packages/blob/9744c9dc4f865cf943776e8c3382b3228b2e7cfd/packages/camera/camera_avfoundation/lib/src/avfoundation_camera.dart#L271 

https://github.com/flutter/packages/blob/9744c9dc4f865cf943776e8c3382b3228b2e7cfd/packages/camera/camera_avfoundation/ios/camera_avfoundation/Sources/camera_avfoundation/FLTThreadSafeEventChannel.m#L31

I don't have much experience with Objective-C, so not sure how to create unit tests for that if necessary but I believe this would be an adecuate solution. I've seen other methods in the plugin that use the same strategy passing the completion object. 

- [] I added new tests to check the change I am making, or this PR is [test-exempt].
- [] All existing and new tests are passing.
mboetger pushed a commit to mboetger/flutter that referenced this pull request Jul 21, 2025
flutter/packages@03a6abb...25d4fa4

2025-06-17 22373191+Hari-07@users.noreply.github.com
[google_maps_flutter] Add a new zIndexInt param to marker and deprecate
zIndex (flutter/packages#8012)
2025-06-17 33691143+JesseRiemens@users.noreply.github.com [pigeon] Use a
const for custom type ids for gobject generated files (flutter#156100)
(flutter/packages#9306)
2025-06-16 22373191+Hari-07@users.noreply.github.com
[google_maps_flutter_platform_(web/android/ios)] Add a new zIndexInt
param to marker and deprecate zIndex (flutter/packages#9408)
2025-06-16 jorgesarpe@gmail.com [camera_avfoundation] fix race condition
when starting image stream on iOS (flutter/packages#8733)
2025-06-16 engine-flutter-autoroll@skia.org Roll Flutter from
f79452e to 8303a96 (21 revisions) (flutter/packages#9433)

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
vashworth pushed a commit to vashworth/packages that referenced this pull request Jul 30, 2025
…n iOS (flutter#8733)

Fixes flutter/flutter#147702 

It's not easy to reproduce this with the example application (as shown in the linked issue). We've been able to reproduce it in our own application which makes heavy usage of Platform channels and different native plugins. After digging into the code we notice that:

The Dart code that starts listening to the event channel was being executed before initializing the stream in the native side. 

https://github.com/flutter/packages/blob/9744c9dc4f865cf943776e8c3382b3228b2e7cfd/packages/camera/camera_avfoundation/lib/src/avfoundation_camera.dart#L271 

https://github.com/flutter/packages/blob/9744c9dc4f865cf943776e8c3382b3228b2e7cfd/packages/camera/camera_avfoundation/ios/camera_avfoundation/Sources/camera_avfoundation/FLTThreadSafeEventChannel.m#L31

I don't have much experience with Objective-C, so not sure how to create unit tests for that if necessary but I believe this would be an adecuate solution. I've seen other methods in the plugin that use the same strategy passing the completion object. 

- [] I added new tests to check the change I am making, or this PR is [test-exempt].
- [] All existing and new tests are passing.
@davidmartos96 davidmartos96 deleted the fix_startstream_race_condition branch October 27, 2025 08:45
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-ios platform-macos

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[camera] regression: startImageStream throws MissingPluginException on iOS

4 participants