Skip to content

Update SpriteMesh in PostUpdate#23591

Open
GiantBlargg wants to merge 2 commits intobevyengine:mainfrom
GiantBlargg:late_spritemesh
Open

Update SpriteMesh in PostUpdate#23591
GiantBlargg wants to merge 2 commits intobevyengine:mainfrom
GiantBlargg:late_spritemesh

Conversation

@GiantBlargg
Copy link
Copy Markdown
Contributor

@GiantBlargg GiantBlargg commented Mar 30, 2026

Objective

Fixes #23590

Solution

Move SpriteMesh's add_mesh and add_material to PostUpdate
Sprites spawned during PostUpdate will still exhibit the problem, but this is an improvement.

Testing

Test with the reproduction from #23590 to see that it fixes the problem.

@alice-i-cecile alice-i-cecile added this to the 0.19 milestone Mar 30, 2026
@alice-i-cecile alice-i-cecile added C-Bug An unexpected or incorrect behavior A-Rendering Drawing game state to the screen D-Straightforward Simple bug fixes and API improvements, docs, test and examples S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Mar 30, 2026
@github-project-automation github-project-automation bot moved this to Needs SME Triage in Rendering Mar 30, 2026
@alice-i-cecile alice-i-cecile added the X-Uncontroversial This work is generally agreed upon label Mar 30, 2026
@PVDoriginal
Copy link
Copy Markdown
Contributor

PVDoriginal commented Mar 31, 2026

Wouldn't it be a better fix to turn those systems into observers instead? So they're ran immediately after a sprite mesh is spawned / changed no matter the schedule? Unless there's something blocking that?

@alice-i-cecile
Copy link
Copy Markdown
Member

Observers are not well suited to processing bulk operations. It's also much harder to reason about and control the order that they run in. We should not ad-hoc change systems into observers without very careful analysis and profiling.

@PVDoriginal
Copy link
Copy Markdown
Contributor

Observers are not well suited to processing bulk operations.

Fair enough. What about using the Last schedule instead of PostUpdate then? It's definitely less common for users to add their own systems in that schedule, so it seems like a better option altogether.

@PVDoriginal
Copy link
Copy Markdown
Contributor

Also, it should be noted that these systems were an ad-hoc solution in the first place, meant to be reworked into something more long-term later down the line (possibly after the material unification).

But if this change makes them more pleasant in the short-term, I have no problems with it.

@GiantBlargg
Copy link
Copy Markdown
Contributor Author

GiantBlargg commented Mar 31, 2026

Fair enough. What about using the Last schedule instead of PostUpdate then? It's definitely less common for users to add their own systems in that schedule, so it seems like a better option altogether.

Running the systems in Last reintroduces the problem although I can't seem to figure out why.

I thought it might be check_entities_needing_specialization but running before or after made no difference in my test case. It's possible that running after would produce a delay that my case doesn't catch, so I'll add that ordering.

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

Labels

A-Rendering Drawing game state to the screen C-Bug An unexpected or incorrect behavior D-Straightforward Simple bug fixes and API improvements, docs, test and examples S-Needs-Review Needs reviewer attention (from anyone!) to move forward X-Uncontroversial This work is generally agreed upon

Projects

Status: Needs SME Triage

Development

Successfully merging this pull request may close these issues.

When spawned during Update, SpriteMesh is one frame late compared to Sprite

3 participants