Fix CameraView crash when switching camera on Windows and other CameraView enhancements #2634
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description of Change
Fixes [BUG] CameraView App crashes when switching camera on Windows #2559: In
CameraProvider.windows.cs
, only one instance ofMediaCapture
is instantiated when iterating through thevideoCaptureSourceGroup
. This causes only the firstmediaCapture.InitializeCameraForCameraView()
to be successful. Wrong camera meta data from the first camera, such as the supported resolutions, are added to the subsequentCameraInfo
s.MediaCapture
in each iteration and properly dispose it after useFixes [BUG] SIGABRT on iOS when Permissions.Camera not Granted #2519:
As per [BUG] SIGABRT on iOS when Permissions.Camera not Granted #2519 (comment):
PermissionException
and let consumers respondAlso found that unnecessary calls to
CameraProvider.RefreshAvailableCameras()
are scattered throughout the code, which is a time consuming operation especially on Windows. IMO this call is only necessary when theCameraProvider
is initialized, or when consumer of the API knows that available cameras on device has been updated (e.g. external camera has been plugged in after the initialization)InitializeAsync
task inCameraProvider
, which is automatically started to initialize the camera list, and can be awaited by the consumer. (This might need more consideration as it change the API ?)RefreshAvailableCameras()
calls throughoutCameraManager
CameraProvider
. This could potential be the solution to [BUG] CameraView on Android not recognizing external cameras #2272?Also fixes a few issues in
CameraViewPage
andCameraViewViewModel
:Cameras
observable in the view model, and make sure it's assigned after theCameraProvider
is initialized so that camera list is not empty.Linked Issues
PR Checklist
approved
(bug) orChampioned
(feature/proposal)main
at time of PRAdditional information