mirror of
https://github.com/moonlight-stream/moonlight-ios.git
synced 2025-07-01 15:26:11 +00:00
Fix crash presenting the loading frame while old one is still dismissing
This commit is contained in:
parent
d18c713684
commit
5028eaed59
@ -30,18 +30,46 @@
|
||||
|
||||
- (void)showLoadingFrame:(void (^)(void))completion {
|
||||
if (!presented) {
|
||||
Log(LOG_I, @"Loading frame presenting start");
|
||||
presented = YES;
|
||||
[[self activeViewController] presentViewController:self animated:NO completion:completion];
|
||||
[[self activeViewController] presentViewController:self animated:NO completion:^{
|
||||
Log(LOG_I, @"Loading frame presenting complete");
|
||||
if (completion) {
|
||||
completion();
|
||||
}
|
||||
}];
|
||||
}
|
||||
else if (completion) {
|
||||
Log(LOG_E, @"Loading frame already shown!");
|
||||
completion();
|
||||
}
|
||||
}
|
||||
|
||||
- (void)dismissLoadingFrame:(void (^)(void))completion {
|
||||
if (presented) {
|
||||
presented = NO;
|
||||
[self dismissViewControllerAnimated:NO completion:completion];
|
||||
Log(LOG_I, @"Loading frame hiding start");
|
||||
[self dismissViewControllerAnimated:NO completion:^{
|
||||
Log(LOG_I, @"Loading frame hiding complete");
|
||||
|
||||
// Since presented is set to NO here rather than
|
||||
// immediately in dismissLoadingFrame, we may
|
||||
// falsely avoid displaying the loading frame if
|
||||
// a dismiss is in progress while attempting to show
|
||||
// the frame. That's preferable to crashing due to
|
||||
// displaying the same VC twice though.
|
||||
//
|
||||
// This scenario can happen if the app is suspended
|
||||
// while the dismiss is in progress then on resume
|
||||
// it attempts to display it again before the dismiss
|
||||
// completes. It can be reproduced by rapidly pressing
|
||||
// Home and switching back to Moonlight while in the app grid.
|
||||
// It reproduces more easily if the VC transitions are animated.
|
||||
self->presented = NO;
|
||||
|
||||
if (completion) {
|
||||
completion();
|
||||
}
|
||||
}];
|
||||
}
|
||||
else if (completion) {
|
||||
completion();
|
||||
|
Loading…
x
Reference in New Issue
Block a user