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 20.1.0 no longer closes Realms when stopping Unity player #3700

Open
peachypixels opened this issue Feb 28, 2025 · 1 comment
Open

Comments

@peachypixels
Copy link

peachypixels commented Feb 28, 2025

What happened?

Hello!

I'm noticing different behaviour between 12.5.0 and 20.1.0 with regards to quitting the Unity player and open Realms (see repro steps)

I've no idea if this happens when running on production\device builds. It doesn't appear to be causing any issues in on-device beta testing, but maybe OS sandboxing is 'helping' here with regards to open files \ file handles.

I can see that the closing\cleanup call originates from Initializer.Initialize that then calls NativeCommon.CleanupNativeResources on the Unity Application.quitting callback.

There are some subtle differences between the two versions, but I'm not in a position to look any further into the issue. Sorry.

So just raising it here in-case someone is able to confirm it's not a bug or that they can investigate further.

Repro steps

Running in Unity then stopping the player, the following used to occur with (12.5.0)...

  1. Realm is open
  2. Unity player is stopped (but not closed)
  3. Logging [Realm.SDK Info: Realm: Force closing all native instances: Application is exiting]
  4. Logging [Realm.SDK Info: Realm: Closed all native instances in NN ms]
  5. Realm is closed (tested by attempting to rename file)

But with (20.1.0) the following occurs...

  1. Realm is open
  2. Unity player is stopped (but not closed)
  3. Realm is still open (tested by attempting to rename file)

Version

Unknown

What Atlas Services are you using?

Local Database only

What type of application is this?

Unity

Client OS and version

Windows 10 (22H2)

Code snippets

No response

Stacktrace of the exception/crash you're getting

Relevant log output

@peachypixels
Copy link
Author

peachypixels commented Mar 3, 2025

Some extra info that I should have posted last week.

This issue was replicated (with Unity 2022.3.59f1) by switching between the two different Realm versions.

Assuming Initializer.Initialize is succeeding (highly likely) then I suspect the issue is actually with NativeCommon.CleanupNativeResources

Specifically, the following Realm initialised check...

if (Interlocked.CompareExchange(ref _isInitialized, 0, 1) == 1)

I suspect by the time Unity invokes the quitting callback, the Realm initialised flag is false (or 0) even though Realm hasn't closed\released what it needs to.

Anyway, hopefully this helps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant