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

Take focus from game during calls on iOS #6462

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

frenzibyte
Copy link
Member

@frenzibyte frenzibyte commented Dec 17, 2024

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.

Visual indicators do not help when the app is sent to the background.
@peppy
Copy link
Member

peppy commented Dec 17, 2024

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.

@frenzibyte
Copy link
Member Author

frenzibyte commented Dec 17, 2024

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.

@peppy peppy self-requested a review February 14, 2025 09:40
@peppy
Copy link
Member

peppy commented Feb 14, 2025

@frenzibyte I found the handling of sdl events locally in IOSWindow pretty ugly, so I've refactored a bit to avoid this. It's still not pretty, but it's the best I can come up with. cc @Susko3 for a quick check.

peppy
peppy previously approved these changes Feb 14, 2025
@peppy
Copy link
Member

peppy commented Feb 14, 2025

Requesting a second set of eyes on this (low priority) @ppy/team-client.

isActive.Value = focused = value;
}
}
public bool Focused { get; private set; }
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
public bool Focused { get; private set; }
public bool Focused { get; protected set; }

To fix Android build.

Copy link
Member

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.

Copy link
Member

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;
Copy link
Member

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:

  1. Play osu!
  2. Get a call
    • game is paused as expected
  3. Answer call (so that osu! goes to the background)
  4. Go back to osu!
    • game is focused, but IsActive == false, leading to weird behaviour (likely: input doesn't work, the game cannot be unpaused)
  5. End call
  6. 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.

Copy link
Member

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.

Copy link
Member Author

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.

Copy link
Member

@Susko3 Susko3 Feb 15, 2025

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?

Copy link
Member Author

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.

Copy link
Member

@peppy peppy Feb 16, 2025

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.

@Susko3
Copy link
Member

Susko3 commented Feb 14, 2025

Everything else seems fine to me.

@peppy peppy self-requested a review February 16, 2025 12:43
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.
3 participants