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

Improve Android and iOS Focus/Unfocus MainLoop Notifications #8453

Closed
ztc0611 opened this issue Nov 17, 2023 · 7 comments
Closed

Improve Android and iOS Focus/Unfocus MainLoop Notifications #8453

ztc0611 opened this issue Nov 17, 2023 · 7 comments

Comments

@ztc0611
Copy link

ztc0611 commented Nov 17, 2023

Describe the project you are working on

A mobile game.

Describe the problem or limitation you are having in your project

Some functionality is difficult to access and others is missing in relation to apps sent to the background. The missing functionality on iOS could be used as part of an autosave system, as long as the saving process takes less than 5 seconds. (https://developer.apple.com/documentation/uikit/uiapplicationdelegate/1622997-applicationdidenterbackground, A warning should probably be included in any relevant documentation that if it takes longer than "approximately five seconds" the app will be completely killed.)

Describe the feature / enhancement and how it helps to overcome the problem or limitation

Implements missing functionality on iOS and makes development easier for both platforms.

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

This will implement NOTIFICATION_APPLICATION_RESUMED and NOTIFICATION_APPLICATION_PAUSED on iOS, allowing the user to know for certain the app has entered the background instead of just being unfocused. applicationWillResignActive (the only lose focus signal from iOS Godot can currently process) being triggered doesn't necessarily mean the app is going to go into the background, as things like an incoming phone call will send that signal.

I also think that NOTIFICATION_APPLICATION_FOCUS_IN and NOTIFICATION_APPLICATION_FOCUS_OUT should be implemented on iOS and Android. The implementation should be relatively basic, as they are both already wired to fire NOTIFICATION_WM_WINDOW_FOCUS_IN and NOTIFICATION_WM_WINDOW_FOCUS_OUT upon their respective OS signaling they have lost focus.

If this enhancement will not be used often, can it be worked around with a few lines of script?

NOTIFICATION_APPLICATION_FOCUS_IN and NOTIFICATION_APPLICATION_FOCUS_OUT can be worked around, but on iOS NOTIFICATION_APPLICATION_RESUMED and NOTIFICATION_APPLICATION_PAUSED has no equivalent.

Is there a reason why this should be core and not an add-on in the asset library?

This cannot be an add-on.

@ztc0611 ztc0611 changed the title Improve Android/iOS Focus/Unfocus Notifications Improve Android and iOS Focus/Unfocus MainLoop Notifications Nov 17, 2023
@ztc0611
Copy link
Author

ztc0611 commented Nov 17, 2023

I have a "first draft" of this ready to go since I wanted it for my own purposes even if this isn't accepted, I have tested it on both iOS 17 and Android 12.

@Calinou
Copy link
Member

Calinou commented Nov 17, 2023

cc @m4gr3d

I also think that NOTIFICATION_APPLICATION_FOCUS_IN and NOTIFICATION_APPLICATION_FOCUS_OUT should be implemented on iOS and Android. The implementation should be relatively basic, as they are both already wired to fire NOTIFICATION_WM_WINDOW_FOCUS_IN and NOTIFICATION_WM_WINDOW_FOCUS_OUT upon their respective OS signaling they have lost focus.

Android tablets and desktop mode (such as DeX) have multi-window support, so unfocusing the window might mean something different than you'd expect (i.e. it could behave the same as on desktop platforms).

@ztc0611
Copy link
Author

ztc0611 commented Nov 18, 2023

When the time comes, should I split the PRs into an iOS fork and an Android fork due to the different considerations? iPadOS does support multi window, but Godot doesn't support it at the moment, so it's a bit simpler to execute.

@Calinou
Copy link
Member

Calinou commented Nov 18, 2023

When the time comes, should I split the PRs into an iOS fork and an Android fork due to the different considerations? iPadOS does support multi window, but Godot doesn't support it at the moment, so it's a bit simpler to execute.

I think it'd be better to have separate PRs for Android and iOS indeed.

@ztc0611
Copy link
Author

ztc0611 commented Nov 18, 2023

I think it'd be better to have separate PRs for Android and iOS indeed.

Should I go ahead and open them on the main project? I don't remember the approval process for proposals.

@Calinou
Copy link
Member

Calinou commented Nov 19, 2023

Should I go ahead and open them on the main project?

Sure 🙂

@akien-mga
Copy link
Member

Implemented by godotengine/godot#85100.

@akien-mga akien-mga added this to the 4.3 milestone Feb 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants