Skip to content

Conversation

terrakok
Copy link
Member

@terrakok terrakok commented Jul 4, 2025

iOS Safari doesn't request a focus when the app is loaded or a user returns to the tab.
So, we decided to trigger ON_RESUME event on each touch event.

Fixes https://youtrack.jetbrains.com/issue/CMP-8014

Testing

This should be tested by QA

Release Notes

Fixes - Web

  • Web Lifecycle triggers START/STOP events on the visibilitychange callback now.
  • Lifecycle fix on iOS Safari: now touch events trigger ON_RESUME because Safari ignores interactions and doesn't request the focus

@terrakok terrakok requested a review from eymar July 4, 2025 15:05
// iOS Safari doesn't request focus when the page is shown,
// and the lifecycle doesn't trigger ON_RESUME.
// so, we decided to handle every touch
lifecycle.handleLifecycleEvent(Lifecycle.Event.ON_RESUME)
Copy link
Member

@eymar eymar Jul 4, 2025

Choose a reason for hiding this comment

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

Could we have an if (lifycecle.currentState != ON_RESUME) { handle on resume... }?
So the handler code won't be invoked on every touch event which can happen frequently and this way we skip a couple of extra function calls on every event.

Copy link
Member Author

Choose a reason for hiding this comment

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

there is already a check inside:

private fun moveToState(next: State) {
        if (state == next) {
            return
        }

Copy link
Member

@eymar eymar Jul 4, 2025

Choose a reason for hiding this comment

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

yeah, I saw that :)
I'd like to avoid the extra 3 function calls.

Potentially: 120 FPS, 1 event per frame -> 120 * 3 = 360 redundant function calls / second.

@ApoloApps
Copy link

This behaviour should only be IOS safari specific, i dont see why this has to be applied on web desktop

@terrakok
Copy link
Member Author

terrakok commented Jul 4, 2025

There are no changes in the behavior in the desktop web

@terrakok terrakok merged commit eb20b15 into jb-main Jul 7, 2025
12 checks passed
@terrakok terrakok deleted the k.tskh/CMP-8014 branch July 7, 2025 10:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants