Skip to content
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

Deactivate game on iOS when sent to background or an incoming call is triggered #6449

Closed
wants to merge 3 commits into from

Conversation

frenzibyte
Copy link
Member

Was hoping that iOS doesn't make me add extra handling for the "incoming call" part but turns out it does (presumably because calls changed from a full app transition to a status bar notification). I considered not handling it altogether but as soon as the user receives a call, the beatmap freezes (as per the issue thread) as the audio is taken away by the presence of the call, and the freeze does not go away until the call is gone. If enough time passes while the beatmap is frozen, osu! dismisses the score from submission due to the audio playback error.

Copy link
Member

@Susko3 Susko3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't the window losing focus be handled by SDL? I.e. isn't this an SDL bug?

Maybe we're handling some events improperly, perhaps we should consider the window to be inactive when we get some events from the event watch (events like "will enter background", "did enter foreground", etc).


callObserver = new IOSCallObserver(
incomingCall: () => Focused = false,
endedCall: () => Focused = true);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I end a call when the game is not active (in the background, as I'm probably in the phone app), does it trigger this and make the game Focused?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good one, this call observer component is completely detached from whether the app is in foreground or background. This should be addressed in ab7cafa

@frenzibyte
Copy link
Member Author

frenzibyte commented Dec 10, 2024

Good observation. There are two things relevant to this:

  1. We don't seem to update the game's focus state on such events for some reason (we should also specifically use "will enter background" and "did enter foreground" to achieve the desired effect).
  2. Apparently these events are straight up broken on iOS, they are never triggered. SDL testing instances work just fine. Investigating...

Additionally this will probably still not handle the "someone is calling" case despite SDL promising that in the wiki, seeing how the events are implemented. And that's likely happening for the same reason mentioned in OP (iOS changing calls to status bar notifications). I think we will still have to handle that case manually because it's specific to us, as we're a rhythm game, where everything is powered by the audio device.

@frenzibyte
Copy link
Member Author

Reported the issue I was seeing on (2) to SDL: libsdl-org/SDL#11627. I think we'll have to move on with what I have in diff for now, I'll add relevant comments and address the scenario noted above.

@frenzibyte
Copy link
Member Author

Will close and split the call handling part now that #6453 has been merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Beatmap freezes when answering a call while playing.
2 participants