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

Stutter on iOS devices caused by touch input events #32139

Closed
AlexRixhardson opened this issue Sep 14, 2019 · 13 comments
Closed

Stutter on iOS devices caused by touch input events #32139

AlexRixhardson opened this issue Sep 14, 2019 · 13 comments

Comments

@AlexRixhardson
Copy link
Contributor

Godot version:
3.1.1. stable

OS/device including version:
iOS 12 - iPad Mini 2

Issue description:
Game works with solid 60 FPS until player starts touching the screen. FPS drops to approx. 57 once the player starts touching the screen which causes apparent stuttering. Cannot reproduce on an Android device.

Steps to reproduce:

  • Run minimal reproduction project on an iPad Mini 2 or an equivalent device (do not run on high end devices, such as iPhone X, as this problem cannot be reproduced on them)
  • Start dragging fingers across the screen and after a few seconds you should start seeing FPS drop

Minimal reproduction project:
Archive.zip

@AlexRixhardson
Copy link
Contributor Author

Some additional info: the problem is present in 3.2 master branch as well.

I tried to comment out some of the code from Godot (hoping that stutter would disappear), but to no avail. The stutter is still present in low-end device (such as iPad Mini 2) when player drags finger across the screen, even though dragging is effectively not working anymore after commenting out all of the following:

in /platform/iphone/gl_view.mm:

		// Process all input events
		// while (CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0, TRUE) == kCFRunLoopRunHandledSource);

also in /platform/iphone/gl_view.mm:

  • complete method (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event

in /platform/iphone/os_iphone.cpp:

  • complete body of method OSIPhone::touch_drag
  • line input->parse_input_event(event_queue[i]); in function OSIPhone::iterate()

It seems that I am looking at the wrong pieces of code for the cause of the stuttering issue. Does anyone who is more familiar with the structure of Godot's iOS code know where roughly could the cause be? Where could I look? :-/

@KoBeWi
Copy link
Member

KoBeWi commented Aug 30, 2020

Can anyone still reproduce this bug in Godot 3.2.3 rc4 or any later release?

@akien-mga
Copy link
Member

No answer, so closing. Please comment if you can still reproduce it, and make sure that an up-to-date reproduction project is included.

@djrain
Copy link

djrain commented Sep 10, 2022

Seems this issue or something similar is still present in 3.5.

Our game uses tap controls, and we're experiencing noticeable stuttering (drops to 56-58 fps) while tapping on iPhone 6s. Whereas skipping the input and triggering the same player movement through code runs perfectly smooth.

Also, Xcode shows a memory leak. In a scene containing only an FPS label, the app's memory use increases precisely when tapping the screen and doesn't go back down. It only increases on taps (not hold/swipe), and increases faster as more fingers are used. FPS degrades more and more as the tapping continues, but stays solid at 60 when no input is happening.

Screen Shot 2022-09-10 at 3 19 58 PM

The memory started at 131 MB and increased to 144 within a few minutes of tapping.

It's really a default project apart from the FPS label, but here it is:
iOSTouchStutter.zip

@djrain
Copy link

djrain commented Sep 16, 2022

Unfortunately this issue is kinda preventing us from releasing our game, as the stutters are quite bad, and we haven't found any workaround. I went to try and test this in Godot 4 beta 1 to see if it's present there, but the iOS builds are currently broken.

I'm happy to poke around myself if need be, but I'm not familiar with the internals here, so any hints or direction would be appreciated!

@tbveralrud
Copy link
Contributor

I believe #69200 fixed this, but I'll let @djrain verify this claim.

@djrain
Copy link

djrain commented Feb 19, 2023

Yes, our testing suggests that #69200 fixes this.

@KoBeWi KoBeWi closed this as completed Feb 19, 2023
@akien-mga akien-mga added this to the 3.6 milestone Feb 19, 2023
@djrain
Copy link

djrain commented Apr 21, 2023

Unfortunately, it seems I was mistaken, or my previous test was a fluke somehow - there is still a serious stuttering problem.

In 3.6 beta 1, the memory leak is fixed, but tapping causes FPS to drop significantly (using same MRP I uploaded previously). I also re-tested in 3.5.1 with #69200 and the stuttering is present there too. This is on an iPhone 14 Pro Max.

EDIT: tested in Godot 4.0 stable, stuttering present there as well.

Is anyone able to confirm this?

@akien-mga akien-mga reopened this Apr 21, 2023
@tbveralrud
Copy link
Contributor

I'll look soon. Will do so on an iPhone 12 Pro.

@tbveralrud
Copy link
Contributor

I am not able to reproduce so far. (iPhone 12 Pro / iOS 16.3.1)
Tested with a very recent 3.x commit (17e0a02).

When idle, the label will consistently read 60 or 59 fps. These values are consistent even when rapidly tapping. I added a tap counter and have tested beyond 4000 taps. Do I need to go far beyond this?

tap counter

Possibly related: Xcode gives me a runtime warning that the user interactive thread is blocked by a lower priority thread.
hang risk

I could investigate this lead to see if it addresses the stutter but it would be a blind fix without a repro.

@djrain
Copy link

djrain commented Apr 24, 2023

I added a tap counter and have tested beyond 4000 taps. Do I need to go far beyond this?

Thanks for testing! No, there's no need to go further. For me, it's quite easy to get FPS to drop significantly (sometimes even below 50) and it happens right from the start.

Here is some quick Xcode profiling I recorded. You can see it starts out normal, with no input. When I start tapping rapidly with three fingers, FPS drops and both CPU and GPU usage increase. Then everything returns to normal after I stop tapping. (this is 3.6 beta 1)

Screen.Recording.2023-04-23.at.10.03.19.PM.mov

Possibly related: Xcode gives me a runtime warning that the user interactive thread is blocked by a lower priority thread.

I've been seeing that as well, could be worth looking into I suppose.

@djrain
Copy link

djrain commented Apr 25, 2023

I suspect the stutter I'm experiencing is specific to devices with Pro Motion display. That would explain why we're not seeing it on iPhone 12 or my iPhone 6s. I've made a new issue #76425 since I do think this particular issue was actually solved.

@tbveralrud
Copy link
Contributor

That's a very good hunch. I'll keep thinking on it.

FWIW, I tested a couple more devices / iOS versions today and couldn't reproduce.
iPad (9th gen) / 16.4.1
iPhone 7 / 15.2.1

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

6 participants