Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Realm .NET 10.0.0-beta.3 crashes on UWP/iOS release build #2169

Closed
kyurkchyan opened this issue Dec 22, 2020 · 6 comments · Fixed by #2170
Closed

Realm .NET 10.0.0-beta.3 crashes on UWP/iOS release build #2169

kyurkchyan opened this issue Dec 22, 2020 · 6 comments · Fixed by #2170
Assignees

Comments

@kyurkchyan
Copy link

kyurkchyan commented Dec 22, 2020

Goals

We’ve decided to update to 10.* version in order to be able to use decimal support and the rest of the new features. We were ready to make the first release with the new SDK, and soon after we made our release build we discovered that the application crashes with the following exception when built in release mode:

Incompatible MarshalAs detected in parameter named 'value'. Please refer to MCG's warning message for more information.

This only happens in release mode though, both on iOS and UWP. This is a major blocker for as and we would have to revert the effort of 2 weeks of refactoring if we decide to revert the changes. Anything we could do to work around this issue?

Expected Results

Realm should work on UWP and iOS Release mode

Actual Results

Realm crashes with above mentioned exception

Steps to Reproduce

  1. Download the sample project RealmPlayground.zip
  2. Set UWP app as startup project
  3. Set the build to Release x64
  4. Launch the app
  5. Observe the exception

Version of Realm and Tooling

  • Client SDK Version: 10.0.0-beta.3
  • Client OS & Version:
    • Build Machine: Windows 10, 18363.1256
    • App Target OS - UWP, iOS 14
@nirinchev
Copy link
Member

When building for iOS, do you get the crash on device or simulator? Also, can you paste the MCG warning message?

@kyurkchyan
Copy link
Author

@nirinchev here is one of the warning messages from Release x64 UWP build. I get 46 of them in that simple sample project! Here is the file with all of them
MCG_warnings.txt

Severity	Code	Description	Project	File	Line	Suppression State
Warning		MCG : warning MCG0001: [MarshalAs(UnmanagedType=(Default), ElementType=(Default))] with type 'Realms.Native.PrimitiveValue' is not supported.This signature is located on 'System.Void Realms.ResultsHandle.NativeMethods.get_value(Realms.ResultsHandle, System.IntPtr, Realms.Native.PrimitiveValue, Realms.NativeException)'.	RealmPlayground.UWP		

As for iOS, I can't repro the issue right now, will get back after Christmas and put more details! Thank you @nirinchev for the support.

@nirinchev
Copy link
Member

Thanks for the update! I think I know what's causing the UWP issue - it's a .net native issue that I'll need to find a workaround for. It was present in 5.x too, but with 10.x is now affecting a much broader API surface.

I hope to have an update after Christmas. As for the iOS issue - I don't have a good theory what could be causing it as it's a fundamentally different compiler and we do have much more extensive tests for it. If you do get a repro (or an error message), that would be super helpful!

Happy holidays and I hope we'll be able to quickly resolve this so your team can start 2021 with new app versions 🤞

@nirinchev
Copy link
Member

I believe I have a workaround for this - it's still not entirely clear to me if it's a bug in the .NET native compiler or something that is accidentally working when JIT-ed. In any case, I was able to create a minimal project that reproduced the UWP issue (without Realm) and the workaround appears to fix it.

I plan to file an issue with the repro to see what the MS folks will say, but even if they fix the compiler issue, I don't expect that to be released and available for a few months at least. In the meantime though, I'd be happy to share a pre-release package with the workaround for you to test in your environment (can do it as soon as CI runs and no regressions are reported). To clarify though, as far as I can tell, this is only a problem with the UWP .NET Native compiler and should not affect the Xamarin AOT compiler for iOS. If you do have issues building for release on iOS, it must be a separate issue and I'd be happy to take a look at a repro project.

@nirinchev
Copy link
Member

So the change appears to work and I merged the PR. CI is currently building a package and you'll be able to find it here: https://github.com/realm/realm-dotnet/packages/399835 (should be 509 or newer). You can either go through the elaborate setup of Github packages or just download the .nupkg and reference it from a local folder. We'll push a -beta.4 to NuGet as soon as we resolve an SSL regression from -beta.3 (ETA a few days).

@kyurkchyan
Copy link
Author

kyurkchyan commented Jan 5, 2021

@nirinchev thanks for really quick iteration!
First of all, I tried to reproduce the iOS issue. I couldn't... it seems that some other thing was broken on iOS and I kind of assumed it was the same as UWP, but I was wrong. So, on iOS everything looks ok!

I tried the 509 release on UWP release. And indeed, the issue was resolved. I will wait a bit though until we use it in production :)

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 15, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants