dotnet / maui

.NET MAUI is the .NET Multi-platform App UI, a framework for building native device applications spanning mobile, tablet, and desktop.
https://dot.net/maui
MIT License
22.18k stars 1.74k forks source link

[Windows] MediaPicker.CapturePhotoAsync not working (msix installed) #24098

Open PauchardThomas opened 2 months ago

PauchardThomas commented 2 months ago

Description

MediaPicker not working at all after installing app through .msix (Release mode) !

When launching the app (no admin rmode) :

When launching the app (admin mode) :

https://github.com/user-attachments/assets/d62ee778-827f-4ca9-841e-cfb9072ebcb3

Reproduction repo : https://github.com/PauchardThomas/MauiMediaPickerIssue

Also see the same issue on https://learn.microsoft.com/en-us/answers/questions/1661755/maui-mediapicker-default-capturephotoasync-windows but no solution has been found by Microsoft Team....

What can we do ? We canno't deploy our app on production !

Steps to Reproduce

  1. Generate Windows Release app.
  2. Install the app with .msix file
  3. Launch the app as without admin rights
  4. TakePhoto not working

Reproduction repo : https://github.com/PauchardThomas/MauiMediaPickerIssue

Link to public reproduction project repository

No response

Version with bug

8.0.80 SR8

Is this a regression from previous behavior?

Not sure, did not test other versions

Last version that worked well

Unknown/Other

Affected platforms

Windows

Affected platform versions

Windows 10 (22H2)

Did you find any workaround?

No !

Relevant log output

No response

github-actions[bot] commented 2 months ago

Hi I'm an AI powered bot that finds similar issues based off the issue title.

Please view the issues below to see if they solve your problem, and if the issue describes your problem please consider closing this one and thumbs upping the other issue to help us prioritize it. Thank you!

Open similar issues:

Closed similar issues:

Note: You can give me feedback by thumbs upping or thumbs downing this comment.

MartyIX commented 2 months ago

What can we do ?

Kind of hesitate to suggest it but IMHO it should be fairly easy for you to debug your issue more in detail yourself using MAUI's sandbox project:

MediaPicker implementation for Windows is here: https://github.com/dotnet/maui/blob/main/src/Essentials/src/MediaPicker/MediaPicker.uwp.cs AFAIK.

I would check your issue more in detail but I don't have access to my dev machine at the moment.

PS: The other idea is to check if this part https://github.com/dotnet/maui/blob/main/src/Templates/src/templates/maui-mobile/Platforms/Windows/Package.appxmanifest#L42-L44 is correct and if you don't need some additional capability (given that it works with an admin account and not with an ordinary one).

Zhanglirong-Winnie commented 2 months ago

This issue has been verified using Visual Studio 17.11.0 Preview 7.0(8.0.80). Can repro on Windows platform.

PauchardThomas commented 2 months ago

I was able to reproduce the issue on the maui Essentials.Sample project.

  1. Launch the project on Release
  2. Go to Media Picker Page
  3. Click on Capture Photo
  4. Nothing happened

Details :

https://github.com/dotnet/maui/blob/main/src/Essentials/src/MediaPicker/MediaPicker.uwp.cs

line 126 :

var result = await WinLauncher.LaunchUriForResultsAsync(uri, options, set);`

=> result.Status value is LaunchUriStatus.Unknow then CaptureFileAsync method return null

MartyIX commented 2 months ago

(Permalink is: https://github.com/dotnet/maui/blob/aa83a1909ba69b64f2a496982d8c397330c43599/src/Essentials/src/MediaPicker/MediaPicker.uwp.cs#L126 (for future reference))

What uri, options, and set are passed in?

MartyIX commented 2 months ago

Btw: I have found this workaround in a WinUI bug: https://github.com/microsoft/WindowsAppSDK/issues/1034#issuecomment-1456774014 and https://github.com/dotnet/maui/pull/13220 which implemented current code in MAUI.

There is also some proposal in WinAppSdk https://github.com/microsoft/WindowsAppSDK/pull/4576 for cameras.

PauchardThomas commented 2 months ago

(Permalink is:

https://github.com/dotnet/maui/blob/aa83a1909ba69b64f2a496982d8c397330c43599/src/Essentials/src/MediaPicker/MediaPicker.uwp.cs#L126

(for future reference)) What uri, options, and set are passed in?

https://github.com/user-attachments/assets/962335ee-d510-4029-ba0e-e7b115f739a3

I also launch my repro app (after installed msix) on a Windows 11 PC and it work on it ! Seems to be an OS issue (Windows 10 ?) to launch the Camera App....

My Windows 10 version :

MartyIX commented 2 months ago

I also launch my repro app (after installed msix) on a Windows 11 PC and it work on it ! Seems to be an OS issue (Windows 10 ?) to launch the Camera App....

Interesting find.

My Windows 10 version :

* (winver) : **22H2 (build 19045. 4651)**

* ((Get-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion').ReleaseId) **2009**

Hm, I can see that that OS will be supported only for another year here: https://learn.microsoft.com/en-us/lifecycle/announcements/windows-10-22h2-end-of-support-update and that it is the most up to date version of Windows 10. Hmmm.

I don't have a Windows 10 machine to test. Perhaps, it makes sense to ask here https://github.com/microsoft/microsoft-ui-xaml/discussions or directly in https://github.com/microsoft/WindowsAppSDK/issues/1034.

PauchardThomas commented 2 months ago

The only workaround that I found for now is to the implement the MediaCapture Class to create a camera view and create some buttons to take photo, retry and cancel...

For now i didn't found any workaround to open the Camera App.

Edit : A lib already exist : Camera.MAUI