question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

iOS v15+: App crashes when opening a BottomSheet

See original GitHub issue

First up: Works fine for devices with iOS v16+. Just any iOS version from 15 upwards that I tried crashed.

Steps to reproduce:

  1. Build and deploy sample app for a iOS device (or simulator) with version 15.*
  2. Try to open any bottomsheet
  3. App crashes

Exception that is thrown in the sample app: ObjCRuntime.ObjCException: 'Objective-C exception thrown. Name: NSInvalidArgumentException Reason: +[UISheetPresentationControllerDetent customDetentWithIdentifier:resolver:]: unrecognized selector sent to class 0x12cc00160

Stack Trace
	0   CoreFoundation                      0x000000011112dbb4 __exceptionPreprocess + 242
	1   libobjc.A.dylib                     0x000000011fcfabe7 objc_exception_throw + 48
	2   CoreFoundation                      0x000000011113c73a __CFExceptionProem + 0
	3   CoreFoundation                      0x00000001111320bc ___forwarding___ + 1433
	4   CoreFoundation                      0x00000001111341e8 _CF_forwarding_prep_0 + 120
	5   libxamarin-dotnet-debug.dylib       0x000000010eba6149 xamarin_dyn_objc_msgSend + 217
	6   ???                                 0x000000014f9bcca7 0x0 + 5630577831
	7   libmonosgen-2.0.dylib               0x000000010f36d42a ves_pinvoke_method + 474
	8   libmonosgen-2.0.dylib               0x000000010f35f6a5 interp_exec_method + 3717
	9   libmonosgen-2.0.dylib               0x000000010f35ce53 interp_runtime_invoke + 259
	10  libmonosgen-2.0.dylib               0x000000010f18389d mono_runtime_try_invoke + 157
	11  libmonosgen-2.0.dylib               0x000000010f185a2f mono_runtime_invoke + 95
	12  The49.Maui.BottomSheet.Sample       0x000000010dfc1059 _ZL32native_to_managed_trampoline_101P11objc_objectP13objc_selectorPP11_MonoMethodS0_j + 473
	13  The49.Maui.BottomSheet.Sample       0x000000010dfc0e55 -[__UIGestureRecognizerGenericCB target:] + 69
	14  UIKitCore                           0x000000012b79ef8f -[UIGestureRecognizerTarget _sendActionWithGestureRecognizer:] + 49
	15  UIKitCore                           0x000000012b7a90e9 _UIGestureRecognizerSendTargetActions + 100
	16  UIKitCore                           0x000000012b7a5c55 _UIGestureRecognizerSendActions + 294
	17  UIKitCore                           0x000000012b7a4f91 -[UIGestureRecognizer _updateGestureForActiveEvents] + 725
	18  UIKitCore                           0x000000012b797213 _UIGestureEnvironmentUpdate + 2713
	19  UIKitCore                           0x000000012b7962f2 -[UIGestureEnvironment _updateForEvent:window:] + 902
	20  UIKitCore                           0x000000012bd129c9 -[UIWindow sendEvent:] + 5273
	21  UIKitCore                           0x000000012bce94e8 -[UIApplication sendEvent:] + 825
	22  UIKitCore                           0x000000012bd7f28a __dispatchPreprocessedEventFromEventQueue + 8695
	23  UIKitCore                           0x000000012bd81a10 __processEventQueue + 8579
	24  UIKitCore                           0x000000012bd781b6 __eventFetcherSourceCallback + 240
	25  CoreFoundation                      0x000000011109be25 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
	26  CoreFoundation                      0x000000011109bd1d __CFRunLoopDoSource0 + 180
	27  CoreFoundation                      0x000000011109b1f2 __CFRunLoopDoSources0 + 242
	28  CoreFoundation                      0x0000000111095951 __CFRunLoopRun + 875
	29  CoreFoundation                      0x0000000111095103 CFRunLoopRunSpecific + 567
	30  GraphicsServices                    0x00000001220f6cd3 GSEventRunModal + 139
	31  UIKitCore                           0x000000012bcc9e63 -[UIApplication _run] + 928
	32  UIKitCore                           0x000000012bccea53 UIApplicationMain + 101
	33  libxamarin-dotnet-debug.dylib       0x000000010eb6064a xamarin_UIApplicationMain + 58
	34  libmonosgen-2.0.dylib               0x000000010f36e5f9 do_icall + 345
	35  libmonosgen-2.0.dylib               0x000000010f36d103 do_icall_wrapper + 291
	36  libmonosgen-2.0.dylib               0x000000010f35f4ff interp_exec_method + 3295
	37  libmonosgen-2.0.dylib               0x000000010f35ce53 interp_runtime_invoke + 259
	38  libmonosgen-2.0.dylib               0x000000010f181de8 mono_runtime_invoke_checked + 136
	39  libmonosgen-2.0.dylib               0x000000010f189dfc do_exec_main_checked + 92
	40  libmonosgen-2.0.dylib               0x000000010f2b8e42 mono_jit_exec + 354
	41  libxamarin-dotnet-debug.dylib       0x000000010eba4c77 xamarin_main + 1927
	42  The49.Maui.BottomSheet.Sample       0x000000010dfe96f4 main + 68
	43  dyld                                0x000000010e61ce1e start_sim + 10
	44  ???                                 0x000000010e9c141f 0x0 + 4540077087

Did anyone experience anything similar?

Issue Analytics

  • State:closed
  • Created 3 months ago
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
paulvarachecommented, Jun 16, 2023

It seems obvious now that compilation macros would be applied at pack time and code would be removed from the published dll

I’ve pushed a new version that uses runtime conditionals and ensures all version restricted code runs only on the supported versions.

For the issue of detents other than medium and large on iOS 15, it is something we cannot do anything about. iOS introduced custom detents on iOS16 and even now there are still missing features for it

3reactions
vhugogarciacommented, Jun 15, 2023

@paulvarache I found maybe not a full working workaround but at least we prevent the app to crash on iOS 15 is by adding the following validation. This is just my grain of salt.

if (UIDevice.CurrentDevice.CheckSystemVersion(16, 0))
        {
            SheetPresentationController.InvalidateDetents();
        }

on this line: https://github.com/the49ltd/The49.Maui.BottomSheet/blob/b5635afe5a0aaf380838b7709dd054786d9ad09a/src/Platforms/iOS/BottomSheetViewController.cs#L52

The only bad thing is that on iOS 15 or older versions the specified detent won’t be detected and for instance it will go full screen all the time. I tested it and that is what happened, works OK but in full screen mode for iOS 15 or older.

cc: @troy-ob @DiogoDeAlmeida

Thank you!

Read more comments on GitHub >

github_iconTop Results From Across the Web

App crashes on iOS when using BottomSheetModal ...
When I Open The app its crashed without errors. So I debug it and I noticed when I remove bottom sheet it works...
Read more >
In iOS 15, when the app is restarted, it immediately crashes.
After the iOS 15 update, the following process causes the app to die. Go to the home screen while running the app; Completely...
Read more >
App crashes when trying to initiate fragment on bottomSheet
However, when I test my app and drag my bottomSheet to the top, i get the error message : IllegalStateException : Activity has...
Read more >
Mobile SDKs
We're seeing a LOT of crashes with iOS SDK as of late and even after upgrading to the latest iOS SDK of 15.1.4...
Read more >
About: WordPress – Website Builder (iOS App Store version)
We fixed an issue with the home screen's “Work on a draft post” card. The app will no longer crash when you access...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found