-
-
Notifications
You must be signed in to change notification settings - Fork 6.4k
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
Sudden CPU spike when VertexArray reaches a certain size (1040) #3912
Comments
Looks like I don't have any noticeable increase in CPU usage. |
Did you try just adding chars to see if it suddenly jumps? I have no clue what factors are involved in deciding what the "magic number" is, it could be a hardware thing, |
Can reproduce the issue. Although, at least in my tests, it seems like the high cpu usage is not constant. E.g. the cpu usage might drop after a while to normal values. If I understand correctly, @Tom-Ski had some more constant results in reproducing it. I could not reproduce it on LWJGL3. With SpriteBatch uses VertexArray (when not gles3), using VBO instead seems one way to fix this issue. I think that SpriteBatch might use VA instead of VBO based on tests which might be somewhat outdated now that gles1 is no longer supported. Therefor I added a deprecated Could you check whether, with latest nightly, adding the following line in your create method fixes it? SpriteBatch.defaultVertexDataType = VertexDataType.VertexBufferObject; |
How would that relate to triggering only when certain amount of chars? Wouldn't VA/VBO just result in bigger CPU usage overall? It is possible, just a bit strange IMO. |
This isn't just related to fonts. Its just about the number of vertices in the vertex array. When it hits the magic number (34 font characters, and add on the triangles for the background and other styling in the default uiskin for TextField). Is reproducible by using Sprites alone (52 Sprites). |
@xoppa Sorry for the late reply, I havn't been able to test it until now, but yes, it does indeed seem to fix the issue! I also noticed that turning off vsync (and then instead capping foregroundFPS to 60) also seems to 'fix' it. |
Issue details
Displaying a certain number of chars in a TextArea / TextField / Label (I'm suspecting pretty much everything than renders BitmapFonts?) on a stage, causes sudden increase in CPU usage. The exact number of chars differs depending on unknown circumstances (which font used perhaps?). In the test below, going from 33 to 34 chars in the TextArea (and again from 42 -> 43) causes huge increase in CPU usage. Only tested on desktop/windows. If you get this bug, but the number of chars needed to reproduce is different, please post how many.
Reproduction steps/code
Version of LibGDX and/or relevant dependencies
Tested: 1.7.1 + 1.9.2
Please select the affected platforms
The text was updated successfully, but these errors were encountered: