杀死进程bug
This commit is contained in:
parent
3bcbce71eb
commit
915fa61f0a
@ -91,9 +91,10 @@ class _SCIndexPageState extends State<SCIndexPage>
|
|||||||
});
|
});
|
||||||
String roomId = DataPersistence.getLastTimeRoomId();
|
String roomId = DataPersistence.getLastTimeRoomId();
|
||||||
if (roomId.isNotEmpty) {
|
if (roomId.isNotEmpty) {
|
||||||
SCAccountRepository().quitRoom(roomId).catchError((e) {
|
Provider.of<RtcProvider>(
|
||||||
return true; // 错误已处理
|
context,
|
||||||
});
|
listen: false,
|
||||||
|
).cleanupStaleRoomForColdStart(roomId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -334,6 +334,7 @@ class RealTimeCommunicationManager extends ChangeNotifier {
|
|||||||
Future<RtcEngine>? _rtcEngineInitTask;
|
Future<RtcEngine>? _rtcEngineInitTask;
|
||||||
Future<void>? _rtcEnginePrewarmTask;
|
Future<void>? _rtcEnginePrewarmTask;
|
||||||
Future<void>? _pendingRoomSwitchAgoraLeaveTask;
|
Future<void>? _pendingRoomSwitchAgoraLeaveTask;
|
||||||
|
final Map<String, Future<void>> _coldStartRoomCleanupTasks = {};
|
||||||
String? _joiningChannelId;
|
String? _joiningChannelId;
|
||||||
bool _isRefreshingMicList = false;
|
bool _isRefreshingMicList = false;
|
||||||
bool _isRefreshingOnlineUsers = false;
|
bool _isRefreshingOnlineUsers = false;
|
||||||
@ -433,6 +434,51 @@ class RealTimeCommunicationManager extends ChangeNotifier {
|
|||||||
this.context = context;
|
this.context = context;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void cleanupStaleRoomForColdStart(String roomId) {
|
||||||
|
final normalizedRoomId = roomId.trim();
|
||||||
|
if (normalizedRoomId.isEmpty ||
|
||||||
|
_coldStartRoomCleanupTasks.containsKey(normalizedRoomId)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
late final Future<void> cleanupTask;
|
||||||
|
cleanupTask = _retryExitNetworkRequest(
|
||||||
|
'cold start quit room $normalizedRoomId',
|
||||||
|
() async {
|
||||||
|
if (_isCurrentRoomId(normalizedRoomId)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
final didQuit = await SCAccountRepository().quitRoom(normalizedRoomId);
|
||||||
|
if (!didQuit) {
|
||||||
|
throw StateError('quitRoom returned false');
|
||||||
|
}
|
||||||
|
},
|
||||||
|
).whenComplete(() {
|
||||||
|
if (identical(
|
||||||
|
_coldStartRoomCleanupTasks[normalizedRoomId],
|
||||||
|
cleanupTask,
|
||||||
|
)) {
|
||||||
|
_coldStartRoomCleanupTasks.remove(normalizedRoomId);
|
||||||
|
}
|
||||||
|
if (DataPersistence.getLastTimeRoomId() == normalizedRoomId) {
|
||||||
|
unawaited(DataPersistence.setLastTimeRoomId(""));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
_coldStartRoomCleanupTasks[normalizedRoomId] = cleanupTask;
|
||||||
|
unawaited(cleanupTask);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _waitForColdStartRoomCleanup(String roomId) async {
|
||||||
|
final normalizedRoomId = roomId.trim();
|
||||||
|
if (normalizedRoomId.isEmpty) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
final cleanupTask = _coldStartRoomCleanupTasks[normalizedRoomId];
|
||||||
|
if (cleanupTask == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
await cleanupTask;
|
||||||
|
}
|
||||||
|
|
||||||
bool get roomVisualEffectsEnabled => _roomVisualEffectsEnabled;
|
bool get roomVisualEffectsEnabled => _roomVisualEffectsEnabled;
|
||||||
|
|
||||||
bool get isExitingCurrentVoiceRoomSession =>
|
bool get isExitingCurrentVoiceRoomSession =>
|
||||||
@ -2107,6 +2153,10 @@ class RealTimeCommunicationManager extends ChangeNotifier {
|
|||||||
SCTts.show('Microphone permission is denied.');
|
SCTts.show('Microphone permission is denied.');
|
||||||
throw ArgumentError('Microphone permission is denied.');
|
throw ArgumentError('Microphone permission is denied.');
|
||||||
}
|
}
|
||||||
|
await _waitForColdStartRoomCleanup(roomId);
|
||||||
|
if (!context.mounted) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (roomId == currenRoom?.roomProfile?.roomProfile?.id) {
|
if (roomId == currenRoom?.roomProfile?.roomProfile?.id) {
|
||||||
if (_currentRoomIsEntryPreview ||
|
if (_currentRoomIsEntryPreview ||
|
||||||
_roomStartupStatus == RoomStartupStatus.loading) {
|
_roomStartupStatus == RoomStartupStatus.loading) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user