Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

[Bug] Mono assert while debugging on iOS #15785

Open
LeadAssimilator opened this issue Jul 28, 2023 · 1 comment
Open

[Bug] Mono assert while debugging on iOS #15785

LeadAssimilator opened this issue Jul 28, 2023 · 1 comment
Labels
p/iOS 🍎 s/unverified New report that has yet to be verified t/bug 🐛

Comments

@LeadAssimilator
Copy link

Description

Native iOS device debugging with the mono interpreter enabled can lead to asserts in mono. See mono/mono#19899. While this isn't an XF issue specifically, the mono bug can be partially worked around by changing XF code.

The proposed workaround is to drop the unnecessary .Invoke here Xamarin.Forms.Platform.iOS/Forms.cs#L305

MonoAssertWorkaround.patch (yes a patch - a 7 byte deletion is trivial and not worth any arbitrary PR barriers, sorry)

diff --git "a/Xamarin.Forms.Platform.iOS/Forms.cs" "b/Xamarin.Forms.Platform.iOS/Forms.cs"
index 643fdacb7..6b8ee58ab 100644
--- "a/Xamarin.Forms.Platform.iOS/Forms.cs"
+++ "b/Xamarin.Forms.Platform.iOS/Forms.cs"
@@ -302,7 +302,7 @@ namespace Xamarin.Forms
 
 			public void BeginInvokeOnMainThread(Action action)
 			{
-				NSRunLoop.Main.BeginInvokeOnMainThread(action.Invoke);
+				NSRunLoop.Main.BeginInvokeOnMainThread(action);
 			}
 
 			public Ticker CreateTicker()

Steps to Reproduce

See attached repro sample below with notes of small edits required.

Expected Behavior

Debugging works without mono asserts.

Actual Behavior

Mono asserts.

Basic Information

  • Version with issue: ALL
  • Last known good version: NONE
  • Platform Target Frameworks:
    • iOS: 14.3.1
    • Android: N/A
    • UWP: N/A
  • Android Support Library / AndroidX Version: N/A
  • NuGet Packages: None
  • Affected Devices: All arm64 devices

Environment

Show/Hide Visual Studio info
Microsoft Visual Studio Professional 2022
Version 17.6.5

Build Logs

N/A

Screenshots

N/A

Reproduction Link

While the repro isn't an XF example natively, one can add the XF nuget package, add the XF Init call and replace the AppDelegate.cs:DeviceBeginInvokeOnMainThread method in the sample with XF's Device.BeginInvokeOnMainThread.

https://github.com/mono/mono/files/12180840/XMI8731_M19899.zip

Workaround

Don't use Device.BeginInvokeOnMainThread or variants that call into IOSPlatformServices.BeginInvokeOnMainThread.

@LeadAssimilator LeadAssimilator added s/unverified New report that has yet to be verified t/bug 🐛 labels Jul 28, 2023
@LeadAssimilator
Copy link
Author

Can we get an SR with this workaround applied?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
p/iOS 🍎 s/unverified New report that has yet to be verified t/bug 🐛
Projects
None yet
Development

No branches or pull requests

2 participants