Skip to content

Adaptive Storage Framework: skip main-thread graphic resolve under MP#593

Merged
notfood merged 1 commit intorwmt:masterfrom
sviyh:fix/adaptive-storage-rand-isolation
Apr 25, 2026
Merged

Adaptive Storage Framework: skip main-thread graphic resolve under MP#593
notfood merged 1 commit intorwmt:masterfrom
sviyh:fix/adaptive-storage-rand-isolation

Conversation

@sviyh
Copy link
Copy Markdown
Contributor

@sviyh sviyh commented Apr 25, 2026

Summary

Mirrors bbradson/Adaptive-Storage-Framework#30 as a compat-side stopgap, since AS Framework releases infrequently.

StorageRenderer.SetPrintDataDirty takes a main-thread fast path that calls itemGraphic.Worker.GetGraphicFor, which chains into Graphic_Random.get_MatSingle and consumes Verse.Rand. SaveAndReload runs on the main thread; a fresh process's load runs off-thread via LongEventHandler.QueueLongEvent doAsynchronously. Host and client therefore consume different amounts of Rand from the seeded Map.FinalizeLoading scope, which desyncs the next downstream consumer (RoomTempTracker.equalizeCells.Shuffle, then FreezeManager.DoIceMelting).

Transpile SetPrintDataDirty so the UnityData.IsInMainThread check becomes IsInMainThread && !MP.enabled, forcing the deferred path symmetrically on host and client when an MP session is active. Solo behavior unchanged.

Test plan

  • Builds clean against current MP API
  • Host saves & reloads in MP, client joins after — no desync at next storage-cell affecting tick (was reproducing in FreezeManager.DoIceMelting)
  • Solo (MP not loaded) — IsInMainThread && !MP.enabled stays true, original fast path runs, no rendering regression

Mirrors bbradson/Adaptive-Storage-Framework#30. StorageRenderer.SetPrintDataDirty
takes a main-thread fast path that calls itemGraphic.Worker.GetGraphicFor, which
chains into Graphic_Random.get_MatSingle and consumes Verse.Rand. SaveAndReload
runs on the main thread; a fresh process's load runs off-thread via
LongEventHandler.QueueLongEvent doAsynchronously. Host and client therefore
consume different amounts of Rand from the seeded Map.FinalizeLoading scope,
which desyncs the next downstream consumer (RoomTempTracker.equalizeCells.Shuffle
and FreezeManager).

Transpile SetPrintDataDirty so the UnityData.IsInMainThread check becomes
IsInMainThread && !MP.enabled, forcing the deferred path symmetrically on host
and client when an MP session is active. Acts as a stopgap until the upstream PR
ships in a release.
@notfood
Copy link
Copy Markdown
Member

notfood commented Apr 25, 2026

Looks fine

@notfood notfood merged commit 1053911 into rwmt:master Apr 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants