Ranged-Based for in ULevelStreaming::BroadcastLevelVisibleStatus iterates an array which can become modified during execution if new levels are added.
------------------------------------------------------
ULevelStreaming::BroadcastLevelVisibleStatus iterates the UWorld::StreamingLevels
in a range-based-for, to broadcast OnLevelShown delegates for some levels.
If the implementation of the ULevelStreaming::OnLevelShown delegate invalidates the UWorld::StreamingLevels array, then you'll hit the ensure regarding array changing during ranged-for iteration.
ensureMsgf(Lhs.CurrentNum == Lhs.InitialNum, TEXT("Array has changed during ranged-for iteration!"));
An example would be trying to LoadLevelInstance for level B from within the OnLevelShown delegate for level A. This results in level B being added to UWorld::StreamingLevels.
.
Error: Ensure condition failed: Lhs.CurrentNum == Lhs.InitialNum [Link Removed] [Line: 206]
Error: Array has changed during ranged-for iteration!
Error: Stack:
Error: [Callstack] 0x00007ffe30f871f6 UE4Editor-Core.dll!FWindowsPlatformStackWalk::StackWalkAndDump() [d:\build\++ue4\sync\engine\source\runtime\core\private\windows\windowsplatformstackwalk.cpp:236]
Error: [Callstack] 0x00007ffe30cc0c92 UE4Editor-Core.dll!FDebug::EnsureFailed() [d:\build\++ue4\sync\engine\source\runtime\core\private\misc\assertionmacros.cpp:305]
Error: [Callstack] 0x00007ffe30cdb356 UE4Editor-Core.dll!FDebug::OptionallyLogFormattedEnsureMessageReturningFalseImpl() [d:\build\++ue4\sync\engine\source\runtime\core\private\misc\assertionmacros.cpp:439]
Error: [Callstack] 0x00007ffe27b4ee8e UE4Editor-Engine.dll!ULevelStreaming::BroadcastLevelVisibleStatus() [d:\build\++ue4\sync\engine\source\runtime\engine\private\levelstreaming.cpp:1292]
Error: [Callstack] 0x00007ffe285573d0 UE4Editor-Engine.dll!UWorld::AddToWorld() [d:\build\++ue4\sync\engine\source\runtime\engine\private\world.cpp:2280]
Error: [Callstack] 0x00007ffe27b98a2a UE4Editor-Engine.dll!ULevelStreaming::UpdateStreamingState() [d:\build\++ue4\sync\engine\source\runtime\engine\private\levelstreaming.cpp:567]
Error: [Callstack] 0x00007ffe2859338b UE4Editor-Engine.dll!UWorld::UpdateLevelStreaming() [d:\build\++ue4\sync\engine\source\runtime\engine\private\world.cpp:2864]
There's no existing public thread on this issue, so head over to Questions & Answers just mention UE-64959 in the post.
0 |
Component | UE - Gameplay |
---|---|
Affects Versions | 4.19, 4.20 |
Target Fix | 4.21 |
Created | Oct 8, 2018 |
---|---|
Resolved | Oct 9, 2018 |
Updated | Sep 14, 2021 |