Scene Corruption ONLY when building to ML2

Currently having build issues with the MagicLeap2, related to Asset/Scene Serialisation in Unity 2022.2+.

The solution runs without problem within the Unity Editor, however once built (dev or release) the application crashes immediately on launch displaying the following error: (detailing further in accompanying .txt)

level0 is corrupt, relaunch unity [position out of bounds]

Typically, this pertains to having #if UNITY_EDITOR encompassing serialized properties or methods utilised by those properties. In which there are no longer any (after some rework), however the issue still remains. However, after much investigation and troubleshooting the issue seems to be stemming from Unity 2022.2 itself and various packages (not just ours it turns out).

Not entirely sure if this is an issue with the ML2 or the version of Unity used (minimum supported version). My thoughts are that if the ML2 could support older versions of Unity 2020/2021, the issue would likely be resolved, instead of ONLY having support for an unstable & unreleased version of Unity.

Tests, Investigations and modifications done

  • Removed all #IF UNITY_EDITOR that could affect serialized properties
  • Regenerated Library Folder (deleted & relaunched unity)
  • Ensured Asset Serialisation is set to Force Text
  • Checked meta file for inconsistencies
  • Rebuilt in a new scene
  • Rebuilt in a new project

Anyone else having issues surrounding this? or have a potential solution?

NOTE: Have been asked to post this here by ML2 dev team.

Unity Editor version: 2022.2.0b10
ML2 OS version: B3E.220818.12-R.046-R417
MLSDK version: 1.0.0
Host OS: (Windows/MacOS)

Error messages from logs
Warn;Unity;[XR] Adding ptr for typeid 124491659070168;
Info;Unity;[XR] Loading dll from path;
UnityMain;type=1400 audit(0.0:1294): avc: denied { search } for name="traces" dev="nvme0n1p37" ino=9699331 scontext=u:r:untrusted_app:s0:c108,c256,c512,c768 tcontext=u:object_r:trace_data_file:s0 tclass=dir permissive=0;
Info;Unity;[XR] [XR::Display] Initializing RenderTextures with yflip blit set to 'true';
Warn;Unity;[XR] Adding ptr for typeid 124491659070360;
Info;Unity;[XR] Loading dll from path;
Warn;Unity;[XR] Adding ptr for typeid 124491659071576;
Info;Unity;[XR] Loading dll from path;
Error;Unity;The file '/data/app/com.VISRDynamics-phkaoKfjbdoQCs_Ucp5q_Q==/base.apk/assets/bin/Data/level0' is corrupted! Remove it and launch unity again!;
Error;Unity;[Position out of bounds!];


Although my area is audio, we did bump into this problem and reported it, we can reproduce this issue with different packages and we filed a bug for this with Unity.
In the mean time, i found that as a workaround you can make private some members of your editor classes and use a getter/setter if need access from outside. for example:
public MLPointSource selectedPointSource = null;
private MLPointSource selectedPointSource = null;
This prevents the crash on this class and I added this function to access it when running on device:
public void SetSelectedPointSource(MLPointSource ps)
Again, this seems to be with classes from packages not Unity's classes so far.


1 Like

Please try the following steps to test if this issue is related to the platform:

  1. Build the application as a standard 2D Android App, without the Magic Leap 2 SDK.
  2. If the problem persists try building the application for the x86 architecture.
  3. Test the applications that were built without the Magic Leap 2 SDK using the Android Emulator inside of Android Studio.
  4. Finally, if all of these steps fail, try building for the x86_64 architecture using Unity 2021.1.0b14 and see if the issue resumes.
1 Like

Following up on this. I misunderstood the symptoms of the error. @dcprovencio 's suggestion is the best workaround we've found. We also reported this bug to Unity and are waiting on a fix



1 Like