fix(animation): WASM 안정성 및 부활 동기화 개선

- GamePlayScreen에 SchedulerBinding으로 setState 안전 처리
- AsciiAnimationCard에서 재개 시 specialAnimation 동기화
- 부활 시 isPaused와 specialAnimation 동시 변경 대응
This commit is contained in:
JiWoong Sul
2025-12-26 17:52:43 +09:00
parent 0865f842a0
commit c55530d3be
2 changed files with 22 additions and 2 deletions

View File

@@ -1,6 +1,7 @@
import 'package:flutter/foundation.dart'
show kIsWeb, defaultTargetPlatform, TargetPlatform;
import 'package:flutter/material.dart';
import 'package:flutter/scheduler.dart' show SchedulerBinding, SchedulerPhase;
import 'package:askiineverdie/data/game_text_l10n.dart' as game_l10n;
import 'package:askiineverdie/data/skill_data.dart';
@@ -428,7 +429,18 @@ class _GamePlayScreenState extends State<GamePlayScreen>
if (state != null) {
_checkSpecialEvents(state);
}
setState(() {});
// WASM 안정성: 프레임 빌드 중이면 다음 프레임까지 대기
if (SchedulerBinding.instance.schedulerPhase ==
SchedulerPhase.persistentCallbacks) {
SchedulerBinding.instance.addPostFrameCallback((_) {
if (mounted) {
setState(() {});
}
});
} else {
setState(() {});
}
}
/// 캐로셀 레이아웃 사용 여부 판단

View File

@@ -147,7 +147,15 @@ class _AsciiAnimationCardState extends State<AsciiAnimationCard> {
_timer?.cancel();
_timer = null;
} else {
// 재개: 애니메이션 재시작 (현재 프레임 유지)
// 재개 시: specialAnimation 동기화 (isPaused와 동시에 변경될 수 있음)
// 예: 부활 시 isPaused가 true→false로 바뀌면서 동시에
// specialAnimation이 null→resurrection으로 변경됨
if (widget.specialAnimation != _currentSpecialAnimation) {
_currentSpecialAnimation = widget.specialAnimation;
_updateAnimation(); // _updateAnimation이 타이머 재시작도 처리함
return;
}
// 일반 재개: 애니메이션 재시작 (현재 프레임 유지)
_restartTimer();
}
return;