This commit is contained in:
Savya Bikram Shah
2026-06-02 13:06:40 +05:45
parent 64b383fe6e
commit f81a17e1f5

View File

@@ -50,12 +50,21 @@ public class ColorbookFlowController : IAsyncStartable, IDisposable
public async UniTask StartAsync(CancellationToken cancellation = new CancellationToken()) public async UniTask StartAsync(CancellationToken cancellation = new CancellationToken())
{ {
_scopeCts = CancellationTokenSource.CreateLinkedTokenSource(cancellation); _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<ReturnToMainMenuSignal>(OnReturnToMainMenu); _returnToMainMenuSubscription = _bus.Subscribe<ReturnToMainMenuSignal>(OnReturnToMainMenu);
_loadingScreen.SetProgress(1f); _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(); if (!_navigatingToGameplay) _loadingScreen.Hide();
PrewarmInterstitialAdAsync(_scopeCts.Token).Forget(); PrewarmInterstitialAdAsync(ct).Forget();
} }
private async UniTaskVoid PrewarmInterstitialAdAsync(CancellationToken ct) private async UniTaskVoid PrewarmInterstitialAdAsync(CancellationToken ct)