Unloading Streaming Level causes crash UE 5.1

  • Windows 11
  • Unreal Engine 5.1

I’m trying to load a new streaming level triggered by an actor in a level. The actor stores a variable with the name of the level to load (LoadLevel) and the level to unload itself (UnloadLevel) after the new level is loaded. This actor is not persistent, and there are instances of this actor in all levels.

I’m loading one streaming level using the LoadLevel variable before unloading the streaming level in the UnloadLevel variable. I can’t find any documentation trying to solve this issue anywhere else.

Since this is a VR (Quest 2) game, I’m loading a temporary lightweight transition level in between both levels and unloading the transition level before unloading the UnloadLevel

What’s weird is that I can load/unload from level 1 to level 2 and load level 3, but the editor crashes when I unload level 2 after loading level 3. and I haven’t found a workaround

I’m getting this error when unloading the UnloadLevel:

Assertion failed: ShareOriginRefCount == 0 [File:D:\build++UE5\Sync\Engine\Source\Runtime\Engine\Private\SceneView.cpp] [Line: 356] FSceneViewStateReference: ShareOrigin view states must be destroyed before their target.

To be honest, it is hard to understand what seem to be the issue without having good knowledge of your project, but this seems like (at least to me), that you are keeping and using reference from the object that is in the world you want to destroy.

1 Like

Sorry for explaining it badly @Bojann . Hopefully this provides enough context. I have tried so many work-around.

This does NOT include the transition level to make it easier. The bug is still present.

This is an overview of the Portal_BASE blueprint, which has an instance in each level, with an exposed variable containing the name of the next level to load.

I can only post one image per post since I’m a new member…

Individuals levels loaded into a persistent level.
Each transition happens when the user unlocks the Portal_BASE pawn, and a collision event is triggered

This is what the end of the log says:

[2023.04.06-10.17.07:961][700]LogLevel: ActivateLevel /Game/New/Levels/UEDPIE_0_StartLevel 1 1 0
[2023.04.06-10.17.07:964][700]PIE: Server logged in
[2023.04.06-10.17.07:964][700]PIE: Play in editor total start time 0.245 seconds.
[2023.04.06-10.17.07:969][700]LogViewport: Scene viewport resized to 3648x1840, mode Windowed.
[2023.04.06-10.17.07:971][700]LogHMD: Warning: Requesting 10 bit swapchain, but not supported: fall back to 8bpc
[2023.04.06-10.17.07:987][700]LogResonanceAudio: Display: Resonance Audio Listener is initialized
[2023.04.06-10.17.07:996][700]LogRenderer: Warning: Resizing VR buffer to 3648 by 1840
[2023.04.06-10.17.30:948][310]LogHMD: Warning: GetPlayAreaBounds xrGetReferenceSpaceBoundsRect with reference space XR_REFERENCE_SPACE_TYPE_STAGE failed with result XR_SPACE_BOUNDS_UNAVAILABLE. Returning zero vector.
[2023.04.06-10.17.30:977][312]LogProfilingDebugging: Allocated a 1024 x 1024 texture for HMD canvas layer
[2023.04.06-10.17.31:614][358]LogLevel: ActivateLevel /Game/New/Levels/UEDPIE_0_MirrorMe 1 1 0
[2023.04.06-10.17.31:622][358]LogScript: Warning: Script Msg: Attempted to access index 0 from array ‘CallFunc_GetAllActorsOfClass_OutActors_1’ of length 0 in ‘/Game/New/BP/Hat.Hat_C:ExecuteUbergraph_Hat’!
[2023.04.06-10.17.31:622][358]LogScript: Warning: Last function called:
/Game/New/BP/Hat.Hat_C.ExecuteUbergraph_Hat

[2023.04.06-10.17.31:656][359]LogLevel: ActivateLevel /Game/New/Levels/UEDPIE_0_StartLevel 0 0 0
[2023.04.06-10.17.31:716][360]LogUObjectHash: Compacting FUObjectHashTables data took 0.61ms
[2023.04.06-10.17.33:358][448]LogHMD: Warning: GetPlayAreaBounds xrGetReferenceSpaceBoundsRect with reference space XR_REFERENCE_SPACE_TYPE_STAGE failed with result XR_SPACE_BOUNDS_UNAVAILABLE. Returning zero vector.
[2023.04.06-10.17.33:912][476]LogLevel: ActivateLevel /Game/New/Levels/UEDPIE_0_DistanceVibration 1 1 0
[2023.04.06-10.17.33:939][477]LogLevel: ActivateLevel /Game/New/Levels/UEDPIE_0_MirrorMe 0 0 0
[2023.04.06-10.17.34:000][478]LogOutputDevice: Warning:

Script Stack (0 frames) :

[2023.04.06-10.17.34:015][478]LogWindows: Error: appError called: Assertion failed: ShareOriginRefCount == 0 [File:D:\build++UE5\Sync\Engine\Source\Runtime\Engine\Private\SceneView.cpp] [Line: 356]
FSceneViewStateReference: ShareOrigin view states must be destroyed before their target.

[2023.04.06-10.17.34:015][478]LogWindows: Windows GetLastError: The operation completed successfully. (0)

I’ve made an actor stored in the persistent level, and I’m still getting the same error after switching between levels two times (loading and unloading). The order of the loading of the levels does not matter. As long as I switch two times between levels, it crashes.

I placed this simple pawn in the persistent level to trigger the loading and unloading of streaming levels.

I’ve also tried in Unreal 5.2 Preview 2, and still get the same error.

Just for the sake of debugging: Have you tried unloading the streaming level first, and then loading your next level after that has completed; and does that work without causing this issue?

1 Like

Thanks for your input. I just tried now, still have the same error. This seems like some bug, but I cannot find a workaround.

Yeah this is really strange. I am not sure what’s going on either. Sorry :frowning:

@Nokide I have exactly the same proble!!! I have a local multiplayer application on the HTC Vive with the server running on windows 11, and all levels load fine EXCEPT FOR THE ONE LEVEL I can’t get out of without the whole app crashing. But I don’t actually add anything from that level to my player character or anything like that… have you by any chance found a solution?