-
Notifications
You must be signed in to change notification settings - Fork 425
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Take focus from game during calls on iOS #6462
base: master
Are you sure you want to change the base?
Conversation
9cab94f
to
59cfeb6
Compare
Visual indicators do not help when the app is sent to the background.
e356b00
to
38c18b0
Compare
To clarify, this is avoiding the game becoming unusable when a phone call arrives? Because your description sounds like this is an optional change, and not having it would just mean that the phone call notification shows on top of the game. Maybe you could show a video of what happens with/without this to clarify. |
I briefly mentioned it in #6449 (comment) but forgot to mention here. This change is mandatory for osu!, otherwise when someone receives a call the beatmap freezes and osu! thinks the audio system is at fault and excludes the score from submission. The change fixes the issue by killing focus and taking gameplay to pause screen immediately. |
@frenzibyte I found the handling of sdl events locally in |
Requesting a second set of eyes on this (low priority) @ppy/team-client. |
isActive.Value = focused = value; | ||
} | ||
} | ||
public bool Focused { get; private set; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
public bool Focused { get; private set; } | |
public bool Focused { get; protected set; } |
To fix Android build.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd rather fix this by updating android code if we can.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Susko3 can you test the android change i committed?
UpdateActiveState(); | ||
} | ||
|
||
protected override bool ShouldBeActive => base.ShouldBeActive && !inCall; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While it fixes the issue, I think that forcing the game to be inactive when a call is in progress isn't fully correct.
Image this scenario:
- Play osu!
- Get a call
- game is paused as expected
- Answer call (so that osu! goes to the background)
- Go back to osu!
- game is focused, but
IsActive == false
, leading to weird behaviour (likely: input doesn't work, the game cannot be unpaused)
- game is focused, but
- End call
- Go back to osu!
- everything is as expected
Instead of the game checking if a call is in progress, I think it should check if a call is currently ringing. Looking at the apple docs, I would consider a call to be ringing iff:
!isOutgoing &&
!hasConnected &&
!hasEnded &&
!isOnHold
.
I think it's fine to force the game to be inactive when a call is ringing, as the user is focused on answering or declining the call.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cc @frenzibyte, looks better than what you have.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would be more optimal, but the audio system always remains frozen while a call is active, from the point of ringing until the call is ended. Therefore it doesn't help to make the game focused while a call is active (the user would be faced with a frozen beatmap and they will receive the "audio is not working" message etc.).
If anything, we should prevent the user from trying to unpause the game during a call, but that's pretty much follow-up effort for this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the audio system always remains frozen while a call is active
😳 Is this how other games behave? If not, maybe something is wrong with BASS.
Is this documented somewhere?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Initial testing with Arcaea showed much proper handling. When an incoming call is triggered, the level still continues progressing, the audio stops for a short time but returns back, and after accepting a call the audio remains working.
I'll report this to BASS.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Honestly let's just go with what we have for now. The above scenario is an edge case of an edge case. We can iterate.
Everything else seems fine to me. |
Again, this is not normal behaviour of any iOS app, as incoming calls have recently been acting more like a glorified notification than a full-screen overlay. However, as a rhythm game, exclusive access to the audio is required for the game to function appropriately, therefore we have to observe for incoming calls and cut focus from the game in order to be aware that it should not remain operating (i.e. send to pause screen).
Note that this change is made primarily because users would otherwise lose their scores when they get a call, as the beatmap freezes and osu! triggers the "you have an issue with your audio device, score will not be submitted" notification.
The framework may not be exclusively for rhythm games, but I think it's simple to have this anyway until we get a report about it from other framework consumers.