Fix crash when creating actors from OnStart - #851
Merged
adriengivry merged 2 commits intoSep 19, 2026
Merged
adriengivry merged 2 commits into
adriengivry merged 2 commits into
Conversation
Gopmyc
reviewed
Sep 14, 2026
Gopmyc
reviewed
Sep 14, 2026
Gopmyc
suggested changes
Sep 14, 2026
Gopmyc
left a comment
Contributor
There was a problem hiding this comment.
NIT : the PR title ends up as the squashed commit message, and the crash happens when entering play mode rather than during loading. Maybe something closer to the issue title, like "Fix crash when creating actors from OnStart" ?
Paaanaaamaaa
force-pushed
the
fix/actor-loading-crash-844
branch
from
September 15, 2026 02:36
dda31a6 to
3b4914c
Compare
adriengivry
requested changes
Sep 15, 2026
adriengivry
left a comment
Member
There was a problem hiding this comment.
Thanks for contributing! 🎉
Please use the standard PR template https://github.com/Overload-Technologies/Overload/blob/main/.github/pull_request_template.md
Scene::Play iterated over m_actors directly while invoking OnAwake, OnEnable and OnStart. If a script called Scene::CreateActor from one of these callbacks, m_actors could be reallocated mid-loop, invalidating the iterators and causing an access violation in Actor::IsActive. Iterating over a copy of m_actors, as Update/FixedUpdate/LateUpdate already do, fixes the crash. While fixing this, the actor creation batch that Play wrapped around its callbacks was also removed. CreateActor already runs OnAwake/OnEnable/OnStart immediately on actors created during play, so the batch was redundant. It also introduced a bug: EndBatchActorCreation ran those same callbacks while m_batchActorCreation was still true, so a callback that called Scene::InstantiatePrefab would hit the 'Cannot begin an actor creation batch while another one is still active' assert in Debug, or silently clear m_batchCreatedActors in Release, leaving actors created earlier in the same callback unstarted. EndBatchActorCreation is reverted to swap the pending actors into a local list and reset m_batchActorCreation before invoking any callback, which removes the nesting problem and makes the while loop unnecessary. Fixes Overload-Technologies#844
Paaanaaamaaa
force-pushed
the
fix/actor-loading-crash-844
branch
from
September 16, 2026 02:18
3b4914c to
6ce805d
Compare
adriengivry
approved these changes
Sep 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes a crash when entering play mode caused by creating actors from
OnAwake,OnEnableorOnStart.Scene::Playiterated overm_actorsdirectly while invoking these callbacks. If a script calledScene::CreateActorfrom one of them,m_actorscould be reallocated mid-loop, invalidating the iterators and causing an access violation inActor::IsActive. It only crashed when the actor holding the script wasn't the last one in the scene, because the loop stopped right after the last actor.Scene::Playnow iterates over a copy ofm_actors, the same wayUpdate,FixedUpdateandLateUpdatealready do. The copy is taken once before all three callbacks so actors created duringOnAwakedon't getOnEnable/OnStartcalled twice.While fixing this, the
BeginBatchActorCreation/EndBatchActorCreationPlay's callbacks was removed.CreateActoralready starts actors created during play immediately, so the batch was redundant, and it caused a nested-batch assert when a callback calledScene::InstantiatePrefab.EndBatchActorCreationis reverted to its previous shape: it swaps the pending actors into a local list and clearsm_batchActorCreationbefore running any callback, which removes the nesting problem and makes thewhileloop unnecessary.Related Issue(s)
Fixes #844
Review Guidance
The only functional change is in
Scene::PlayScreenshots/GIFs
None!
AI Usage Disclosure
None!
Checklist