Hi there,
Hoping you could help me with an issue i am getting at present. When choosing to pick a video from the gallery, the video is compressed but then the app crashes, with the exception saying access to the path denied. This looks to be only a bug on iOS 13.
I am on the latest stable version of Xam.Plugin.Media 4.0.1.5
I have followed the sample code how to use Xam.Plugin.Media and the app crashes on the last line
public static async Task
{
await CrossMedia.Current.Initialize();
if (!CrossMedia.Current.IsPickVideoSupported)
{
await Application.Current.MainPage.DisplayAlert("Notice", "Choosing videos from your gallery is currently not supported on your device", "Close");
return null;
}
(Boolean hasPermissions, Permission[] nonGrantedPermissions) permissions = await EnsurePermissions(Permission.Photos, Permission.Storage);
if (!permissions.hasPermissions)
{
await AlertNonGrantedPermissions(permissions.nonGrantedPermissions);
return null;
}
return await CrossMedia.Current.PickVideoAsync();
}
The pick video option doesn't ask for an app name and directory name, this maybe the cause for the crash?
I have these permissions in my info.plist
NSCameraUsageDescription
This app needs access to the camera to take photos.
NSPhotoLibraryUsageDescription
This app needs access to photos.
NSMicrophoneUsageDescription
This app needs access to microphone.
NSPhotoLibraryAddUsageDescription
This app needs access to the photo gallery.
I can confirm I'm seeing the same issue. Tested on iPad pro 11" with multiple versions of iOS 13 beta, including the latest (4).
Do you have a log of the output?
The first line below returns many times while i access the gallery and pick a video to upload. Then when i click 'Choose' i get the below Unauthorized Exception Error
2019-09-23 09:06:14.978 TestAppiOS[282:6083] AX Exchange error: Error Domain=Accessibility Code=0 "Remote service does not respond to _accessibilityMachPort" UserInfo={NSLocalizedDescription=Remote service does not respond to _accessibilityMachPort}
Access to the path '/private/var/mobile/Containers/Data/PluginKitPlugin/D80D544F-4B32-4F0F-BD7B-EC3EB560E08B/tmp/trim.3EF9AC34-E491-41C1-9E91-336EEAA1D072.MOV' is denied.
I also experience a crash on iOS 13 when picking a video. I'm using version 3.1.3 of Xam.Plugin.Media (a little behind, I'm sure).
"SIGABRT: Access to the path is denied."
File.Move (System.String sourceFileName, System.String destFileName)
MediaPickerDelegate+
MediaPickerDelegate+
AsyncMethodBuilderCore+<>c.
NSAsyncSynchronizationContextDispatcher.Apply ()
(wrapper managed-to-native) UIKit.UIApplication.UIApplicationMain(int,string[],intptr,intptr)
@jamesmontemagno here is the exception in the log window:
System.UnauthorizedAccessException: Access to the path '/private/var/mobile/Containers/Data/PluginKitPlugin/BA5D0C0A-47CA-490E-8EB8-05DD1DEDFAC8/tmp/trim.84C1A08C-9585-4DFB-A6F2-0E10556B584B.MOV' is denied. ---> System.IO.IOException: Operation not permitted
--- End of inner exception stack trace ---
at System.IO.FileSystem.DeleteFile (System.String fullPath) [0x0006e] in /Users/builder/jenkins/workspace/xamarin-macios/xamarin-macios/external/mono/external/corefx/src/System.IO.FileSystem/src/System/IO/FileSystem.Unix.cs:217
at System.IO.FileSystem.MoveFile (System.String sourceFullPath, System.String destFullPath) [0x00041] in /Users/builder/jenkins/workspace/xamarin-macios/xamarin-macios/external/mono/external/corefx/src/System.IO.FileSystem/src/System/IO/FileSystem.Unix.cs:182
at System.IO.File.Move (System.String sourceFileName, System.String destFileName) [0x00083] in /Users/builder/jenkins/workspace/xamarin-macios/xamarin-macios/external/mono/external/corefx/src/System.IO.FileSystem/src/System/IO/File.cs:644
at Plugin.Media.MediaPickerDelegate.GetMovieMediaFile (Foundation.NSDictionary info) [0x00222] in /Users/myself/Projects/my_macbook-pro-Release_1.0.1/Project/project.Plugin.iOS/Media/MediaPickerDelegate.cs:565
at Plugin.Media.MediaPickerDelegate.FinishedPickingMedia (UIKit.UIImagePickerController picker, Foundation.NSDictionary info) [0x00141] in /Users/gcadmes/Projects/gcadmes_macbook-pro-MayLake_Release_1.0.1/project/Plugin.iOS/Media/MediaPickerDelegate.cs:58
at System.Runtime.CompilerServices.AsyncMethodBuilderCore+<>c.
at Foundation.NSAsyncSynchronizationContextDispatcher.Apply () [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/13.2.0.42/src/Xamarin.iOS/Foundation/NSAction.cs:178
at at (wrapper managed-to-native) UIKit.UIApplication.UIApplicationMain(int,string[],intptr,intptr)
at UIKit.UIApplication.Main (System.String[] args, System.IntPtr principal, System.IntPtr delegate) [0x00005] in /Library/Frameworks/Xamarin.iOS.framework/Versions/13.2.0.42/src/Xamarin.iOS/UIKit/UIApplication.cs:86
at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x0000e] in /Library/Frameworks/Xamarin.iOS.framework/Versions/13.2.0.42/src/Xamarin.iOS/UIKit/UIApplication.cs:65
at project.iOS.Application.Main (System.String[] args) [0x00001] in /Users/myself/projects/my_macbook-pro-Release_1.0.1/project/project.iOS/Main.cs:17
@jamesmontemagno Seems like after the video compression is complete, the copy of the compressed video is being saved in a no-no directory. At least as of iOS 13.
The exception appears to be happening on line # 574, MediaPickerDelegate.GetMovieMediaFile.
Throws on File.Move(url.Path, path);
I changed it to File.Copy, which seems to have fixed it, but not sure that is the best option at this point.
Yes, I too have experienced this issue with the same exception: Access to the path '/private/var/mobile/Containers/Data/PluginKitPlugin/95528EC9-DB24-438B-A184-F6F57CE9F29D/tmp/trim.C5F7901D-6EDC-406E-9AD4-A0E2F9F12F12.MOV' is denied. Running on ios 13.1
I have the same issues. Just found out when Apple rejected my app update for iOS13 :(
Hope there will be a fix soon ( included with the Multi photo select out of beta)
I have the same issues.
Our app is having the same issue as well. As a workaround, capturing video from within our application works but being able to pick an existing video is a feature we want to provide. @jamesmontemagno Do you have an estimate as to when a fix might be available?
I did what gcadmes did - change to copy instead of move. In closely looking at my debug log, I saw that the exception occurs on System.IO.FileSystem.DeleteFile, and that made me think, a move essentially copies the source file to the destination and then deletes the source, hence, the exception. Apple must have changed the permissions for the private directories to prevent this, which makes sense. I don't see using copy instead of move any issue as gcadmes ('not sure if it's the best option') was worried about. The only downside of this is what happens to all of the non-deleted files in the private directory? Does the OS remove these or do they permanently stay as part of the apps space? Not really sure who can answer that question. If someone does know I'd like to know the answer.
Please send down a PR if they get a fix in.
I just tested ios 13.1 simulator and worked fine with picking a video that I had downloaded from the internet....
You can grab new 4.4.0-beta
Prior to using the new 4.4.0-beta version, I was receiving the "Access to the path ... is deined" error. However, now with the 4.4.0-beta version I'm receiving a 'Could not create file ...mp4. File already exists.' error when a video is selected and compressed. I'm using a iPad Pro with version 13.1.2. Is anyone else encountering this error?
Going to push out a 4.4.1 with a few fix ups. Let me know what you see there.
Works 4 me. Thanks!
4.4.6-beta worked for us. Thanks!
from where i will get 4.4.6-beta for xam.plugin.media ?
Prior to using the new 4.4.0-beta version, I was receiving the "Access to the path ... is deined" error. However, now with the 4.4.0-beta version I'm receiving a 'Could not create file ...mp4. File already exists.' error when a video is selected and compressed. I'm using a iPad Pro with version 13.1.2. Is anyone else encountering this error?
Did you ever get this fixed? I am still having the same issue even with the beta versions. I have tried a few now.
Prior to using the new 4.4.0-beta version, I was receiving the "Access to the path ... is deined" error. However, now with the 4.4.0-beta version I'm receiving a 'Could not create file ...mp4. File already exists.' error when a video is selected and compressed. I'm using a iPad Pro with version 13.1.2. Is anyone else encountering this error?
Did you ever get this fixed? I am still having the same issue even with the beta versions. I have tried a few now.
Update your iPad to the latest software and try again
Prior to using the new 4.4.0-beta version, I was receiving the "Access to the path ... is deined" error. However, now with the 4.4.0-beta version I'm receiving a 'Could not create file ...mp4. File already exists.' error when a video is selected and compressed. I'm using a iPad Pro with version 13.1.2. Is anyone else encountering this error?
Did you ever get this fixed? I am still having the same issue even with the beta versions. I have tried a few now.
Update your iPad to the latest software and try again
Ah you have just reminded me, I was on the current iOS beta! I'm guessing this could be causing an issue!
Most helpful comment
Going to push out a 4.4.1 with a few fix ups. Let me know what you see there.