From f81a17e1f5fe897065679f439809edf1068ca4f3 Mon Sep 17 00:00:00 2001 From: Savya Bikram Shah Date: Tue, 2 Jun 2026 13:06:40 +0545 Subject: [PATCH] fix --- .../ColorbookFlow/System/ColorbookFlowController.cs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/Assets/Darkmatter/Code/Features/ColorbookFlow/System/ColorbookFlowController.cs b/Assets/Darkmatter/Code/Features/ColorbookFlow/System/ColorbookFlowController.cs index 2106d02..aff0099 100644 --- a/Assets/Darkmatter/Code/Features/ColorbookFlow/System/ColorbookFlowController.cs +++ b/Assets/Darkmatter/Code/Features/ColorbookFlow/System/ColorbookFlowController.cs @@ -50,12 +50,21 @@ public class ColorbookFlowController : IAsyncStartable, IDisposable public async UniTask StartAsync(CancellationToken cancellation = new CancellationToken()) { _scopeCts = CancellationTokenSource.CreateLinkedTokenSource(cancellation); + // Grab the token value up front. If the scope is torn down (scene unload) while the + // init below is in flight, the await resumes during disposal — when _scopeCts is already + // disposed and its .Token getter would throw ObjectDisposedException. The captured struct + // stays safe to read. + var ct = _scopeCts.Token; _returnToMainMenuSubscription = _bus.Subscribe(OnReturnToMainMenu); _loadingScreen.SetProgress(1f); - await _drawingCatalog.InitializeAsync(cancellation); + await _drawingCatalog.InitializeAsync(ct); + // scope disposed mid-init; nothing left to do. Check the external token too — it's the + // one VContainer cancels on teardown, and the linked _scopeCts may lag the callback order. + if (cancellation.IsCancellationRequested || ct.IsCancellationRequested) return; + if (!_navigatingToGameplay) _loadingScreen.Hide(); - PrewarmInterstitialAdAsync(_scopeCts.Token).Forget(); + PrewarmInterstitialAdAsync(ct).Forget(); } private async UniTaskVoid PrewarmInterstitialAdAsync(CancellationToken ct)