Xamarin.Forms Ios app => NSInternalInconsistencyException when PickPhotoAsync is executed more than two times
lauditore opened this issue · 1 comments
Bug Information
Version Number of Plugin: 5.0.1
Device Tested On: No access to a physical Ios device
Simulator Tested On: Several Iphone / Ipod14.4 Simulator
Version of VS: VS for mac 8.9.1
Version of Xamarin: Xamarin mac 7.8.2.5 (community) / Xamarin Ios 14.14.2.5 (community)
Versions of other things you are using: Xamarin.Essentials 1.6.1
Steps to reproduce the Behavior
Calling await CrossMedia.Current.PickPhotoAsync(); or PickVideoAsync(); more than two times in the same page instance
Expected Behavior
Open file selector
Actual Behavior
App crashes
Code snippet
Dto.FotoPath = string.Empty;
if (!CrossMedia.Current.IsPickPhotoSupported)
{
throw new Exception("-");
}
else
{
var status = await Permissions.CheckStatusAsync<Permissions.StorageRead>();
if (status != PermissionStatus.Granted)
{
status = await Permissions.RequestAsync<Permissions.StorageRead>();
}
if (status == PermissionStatus.Granted)
{
Foto = await CrossMedia.Current.PickPhotoAsync(new PickMediaOptions
{
//CompressionQuality = 80,
//MaxWidthHeight = 600,
});
if (!string.IsNullOrEmpty(Foto?.Path))
{
Dto.FotoPath = Foto.Path;
}
}
else
{
throw new Exception("-");
}
}
Objective-C exception thrown. Name: NSInternalInconsistencyException Reason: Modifications to the layout engine must not be performed from a background thread after it has been accessed from the main thread.
Native stack trace:
0 CoreFoundation 0x00007fff20421af6 __exceptionPreprocess + 242
1 libobjc.A.dylib 0x00007fff20177e78 objc_exception_throw + 48
2 CoreAutoLayout 0x00007fff59a24c89 -[NSISEngine tryToOptimizeReturningMutuallyExclusiveConstraints] + 0
3 CoreAutoLayout 0x00007fff59a24926 -[NSISEngine _optimizeWithoutRebuilding] + 54
4 CoreAutoLayout 0x00007fff59a24459 -[NSISEngine optimize] + 92
5 CoreAutoLayout 0x00007fff59a1f8c4 -[NSISEngine performPendingChangeNotifications] + 82
6 UIKitCore 0x00007fff24be4dc1 -[UIView(Hierarchy) layoutSubviews] + 491
7 UIKitCore 0x00007fff24bf8504 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 2924
8 QuartzCore 0x00007fff27b1bc2b -[CALayer layoutSublayers] + 258
9 QuartzCore 0x00007fff27b2219d _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 575
10 QuartzCore 0x00007fff27b2df3f _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 65
11 QuartzCore 0x00007fff27a6d44c _ZN2CA7Context18commit_transactionEPNS_11TransactionEdPd + 496
12 QuartzCore 0x00007fff27aa4233 _ZN2CA11Transaction6commitEv + 783
13 MyApp.Xam.Ios 0x000000010eac6cb9 xamarin_dyn_objc_msgSend + 217
Unable to reproduce with latest beta