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

iOS. Investigate 60 FPS limit during scrolling on 120 Hz devices in real world applications #3605

Closed
igordmn opened this issue Sep 1, 2023 · 1 comment
Assignees
Labels
bug Something isn't working ios p:high High priority performance

Comments

@igordmn
Copy link
Collaborator

igordmn commented Sep 1, 2023

In some applications there is still no full 120 FPS during scrolling

Use this FPS counter:

@Composable
fun FPSCounter() {
    LaunchedEffect(Unit) {
        val fpsCounter = org.jetbrains.skiko.FPSCounter(logOnTick = true)
        while (true) {
            withFrameNanos {
                fpsCounter.tick()
            }
        }
    }
}

And scroll some lists in these applications:

https://github.com/chrisbanes/tivi

1.5.0-rc01

[1655239601] FPS 46 (4-139)
[1655241601] FPS 60 (59-61)
[1655243618] FPS 61 (40-140)
[1655245635] FPS 61 (48-318)
[1655247682] FPS 53 (6-143)
[1655249693] FPS 44 (6-125)
[1655251721] FPS 40 (10-120)
[1655253735] FPS 39 (10-121)
[1655255735] FPS 55 (30-143)
[1655257749] FPS 71 (40-138)
[1655259752] FPS 67 (40-252)
[1655261752] FPS 80 (39-153)
[1655263761] FPS 67 (34-143)
[1655265761] FPS 73 (40-264)
[1655267778] FPS 38 (2-142)
[1655269786] FPS 49 (4-141)
[1655271795] FPS 57 (10-150)
[1655273803] FPS 70 (13-201)
[1655275803] FPS 77 (35-135)
[1655277803] FPS 86 (20-290)
[1655279803] FPS 82 (40-251)
[1655281804] FPS 68 (30-158)
[1655283820] FPS 60 (58-61)
[1655285821] FPS 60 (59-61)
[1655287821] FPS 53 (4-137)
[1655289838] FPS 59 (5-378)
[1655291846] FPS 64 (13-141)
[1655293846] FPS 68 (40-139)
[1655295855] FPS 86 (40-146)

1.5.0-rc04

[1654238271] FPS 57 (9-119)
[1654240271] FPS 62 (37-171)
[1654242271] FPS 60 (59-61)
[1654244280] FPS 56 (8-160)
[1654246288] FPS 63 (46-357)
[1654248296] FPS 73 (56-139)
[1654250297] FPS 60 (58-62)
[1654252305] FPS 60 (40-64)
[1654254306] FPS 60 (59-61)
[1654256322] FPS 60 (58-62)
[1654258323] FPS 60 (59-61)
[1654260331] FPS 60 (39-65)
[1654262331] FPS 60 (59-61)
[1654264348] FPS 60 (59-61)
[1654266356] FPS 59 (8-155)
[1654268389] FPS 32 (4-149)
[1654270406] FPS 52 (7-130)
[1654272406] FPS 26 (6-61)
[1654274407] FPS 49 (8-61)
[1654276407] FPS 60 (59-61)

https://github.com/touchlab/DroidconKotlin
1.5.0-dev1080

[2140369259] FPS 101 (12-623)
[2140371268] FPS 100 (60-397)
[2140373270] FPS 100 (61-394)
[2140375272] FPS 100 (58-504)
[2140377273] FPS 99 (58-394)
[2140379274] FPS 96 (38-361)
[2140381276] FPS 95 (32-414)
[2140383286] FPS 83 (4-908)
[2140385287] FPS 101 (59-481)
[2140387289] FPS 102 (58-379)
[2140389291] FPS 100 (58-319)
[2140391300] FPS 99 (61-356)
[2140393303] FPS 99 (60-362)
[2140395304] FPS 102 (43-506)
[2140397306] FPS 99 (38-460)
[2140399307] FPS 101 (59-353)
[2140401308] FPS 98 (52-398)
[2140403311] FPS 97 (60-130)
[2140405311] FPS 101 (60-405)
[2140407321] FPS 104 (61-518)
[2140409323] FPS 99 (54-136)
[2140411325] FPS 99 (61-416)
[2140413334] FPS 99 (56-339)
[2140415344] FPS 104 (60-133)
[2140417354] FPS 101 (55-415)
[2140419355] FPS 100 (61-361)
[2140421357] FPS 103 (61-389)
[2140423359] FPS 100 (60-147)
[2140425369] FPS 100 (61-329)
[2140427370] FPS 98 (17-515)
[2140429372] FPS 95 (37-172)
[2140431383] FPS 96 (42-511)
[2140433384] FPS 101 (59-380)
[2140435385] FPS 103 (60-394)
[2140437388] FPS 99 (61-322)

1.5.0

[2140958059] FPS 55 (3-153)
[2140960060] FPS 60 (58-61)
[2140962062] FPS 60 (58-62)
[2140964072] FPS 62 (58-132)
[2140966074] FPS 98 (55-424)
[2140968075] FPS 96 (55-391)
[2140970078] FPS 85 (49-349)
[2140972079] FPS 100 (55-307)
[2140974080] FPS 96 (51-385)
[2140976090] FPS 73 (58-292)
[2140978091] FPS 60 (58-62)
[2140980093] FPS 60 (58-62)
[2140982096] FPS 71 (50-330)
[2140984105] FPS 80 (37-380)
[2140986106] FPS 68 (38-172)
[2140988108] FPS 95 (46-612)
[2140990109] FPS 88 (40-301)
[2140992111] FPS 88 (44-239)
[2140994112] FPS 66 (54-143)
[2140996114] FPS 60 (59-61)
[2140998116] FPS 60 (54-128)
[2141000117] FPS 60 (59-61)
[2141002119] FPS 60 (59-61)
[2141004129] FPS 61 (55-138)
[2141006130] FPS 60 (58-62)
[2141008132] FPS 60 (59-61)
[2141010142] FPS 61 (55-140)
[2141012143] FPS 60 (59-61)
[2141014145] FPS 60 (59-61)
[2141016154] FPS 61 (55-123)
[2141018156] FPS 60 (59-61)
[2141020158] FPS 60 (59-61)
[2141022159] FPS 60 (58-61)
[2141024169] FPS 61 (55-135)
[2141026171] FPS 60 (58-61)
[2141028172] FPS 60 (59-61)
[2141030182] FPS 61 (55-128)
[2141032184] FPS 60 (59-61)
[2141034185] FPS 60 (58-61)
[2141036187] FPS 60 (53-126)
[2141038189] FPS 60 (58-62)
[2141040198] FPS 91 (56-268)
[2141042200] FPS 98 (38-602)
[2141044202] FPS 100 (55-603)
[2141046204] FPS 103 (55-683)
[2141048205] FPS 60 (41-125)
[2141050206] FPS 60 (53-70)

Hypothesis: VRR drops the screen refresh rate to 60Hz if there are no touches on the screen.

@igordmn igordmn added bug Something isn't working performance p:high High priority ios labels Sep 1, 2023
elijah-semyonov added a commit to JetBrains/compose-multiplatform-core that referenced this issue Sep 13, 2023
## Rationale
If subsequent `setPaused: true:` `setPaused: false` happen on different
main RunLoop jobs, actual restart of CADisplayLink takes 16 ms (two
intervals).

## Proposed Changes
Since invalidation, which triggers unpause, happens asynchronously, we
can avoid that behavior by forcing `needRedraw` call to unpause
CADisplayLink for at least two frames (instead of one).

Remove `getMainDispatcher`. `Dispatchers.Main` works correctly now and
doesn't need a workaround.

## Testing

Test: check that animations are 120hz on 120hz devices, even when there
are no touches tracked.

## Issues Fixed

Fixes: scheduling causing
JetBrains/compose-multiplatform#3605. It's not
the only reason for lower FPS.
elijah-semyonov added a commit to JetBrains/compose-multiplatform-core that referenced this issue Sep 19, 2023
## Proposed Changes

Only use `presentWithTransaction` and transparent `CAMetalLayer` when
UIKit interop is active.

## Testing

Test: N/A

## Issues Fixed

Fixes: occasional frame drops reported in
JetBrains/compose-multiplatform#3605 when iOS
compositor fails to meet frame deadline because of going slow off-screen
rendering path, instead of direct-to-screen.

Composited | Direct
---|---

![Composited](https://github.com/JetBrains/compose-multiplatform-core/assets/4167681/130ec472-1675-4eda-b2cc-fa1e1e84ec1d)
|
![Direct](https://github.com/JetBrains/compose-multiplatform-core/assets/4167681/65ebf09a-7896-4354-9c64-9c0e547a87f6)
@elijah-semyonov
Copy link
Contributor

The most problematic place in this issue was incorrect invalidation logic, it was fixed by JetBrains/compose-multiplatform-core#797

@JetBrains JetBrains locked and limited conversation to collaborators Oct 6, 2023
@JetBrains JetBrains unlocked this conversation Oct 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working ios p:high High priority performance
Projects
None yet
Development

No branches or pull requests

2 participants