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

Script editor becomes intermittently unresponsive on Apple Silicon (M2 pro) mac using Mobile or Forward+ renderer #82675

Closed
lostminds opened this issue Oct 2, 2023 · 7 comments

Comments

@lostminds
Copy link

Godot version

4.2.dev5

System information

Godot v4.2.dev5 - macOS 13.6.0 - Vulkan (Mobile) - integrated Apple M2 Pro - Apple M2 Pro (10 Threads)

Issue description

When using the script editor in Godot on my new M2 Pro mac the editor will occasionally become unresponsive, not responding to key presses or mouse events if using the Mobile or Forward+ renderers. Using the Compatibility renderer the freezes do not occur.

Sometimes the freezes are minor hickups, but sometimes it will freeze the script editor for multiple seconds before it becomes responsive again. The freezes do not seems to be corresponding to anything I can deduce, they can happen while typing any code or sometimes just moving the cursor or entering blank new lines.

This is what I've been able to figure out:

  • The issue seems specific to the script editor, the other parts of the editor seem not to be affected (at least not as noticeably).
  • The issue seems to be specific to apple silicone macs, I've not encountered the issue previously on intel-based macs and when I try 4.2.dev5 on an older intel-based mac running macOS 10.15 I cannot reproduce it.
  • The issue is present in Godot 4.0.4, 4.1.2rc1 as well, so it's not anything new to 4.2.
  • I can see that the script editor cursor blinking is uneven. When opening the script editor it will be blinking evenly, sometimes missing a beat, then after one or two of these freezes happen it will become very erratic often stopping to blink entirely or just sporadically.
  • Since I can discern no apparent pattern as to what input actions cause the freezes I would guess it's due to some script editor-related background process that is for some reason causing the main update/input thread for the script editor to lock up. Probably related somehow to rendering the code editor since it only happens on the vulkan-based renderers.
  • After a freeze any key presses or mouse events that have occurred during the freeze are processed, so they're collected and processed, just with a delay (either on processing or display).
  • The issue is not specific to any project or file. It happens if I start a new project and just open the script editor and create a new script or if I work on an existing project.
  • This issue only happens when the editor is using the Mobile or Forward+ renderers, not when using the Compatibility renderer.

I realize this is may not be much to go on, but since it's a serious issue sometimes making it very hard to work with the script editor I'm opening this issue and would welcome any advice on how to help tracking down the cause.

Steps to reproduce

Use the godot script editor on a m2 pro mac (possibly any apple silicon mac) in a project using the Mobile or Forward+ renderer, create a new script and type some code.

Minimal reproduction project

This does not seem to be project specific.

@akien-mga akien-mga changed the title Script editor becomes intermittently unresponsive on apple silicone (M2 pro) mac using Mobile or Forward+ renderer Script editor becomes intermittently unresponsive on Apple Silicon (M2 pro) mac using Mobile or Forward+ renderer Oct 2, 2023
@Calinou
Copy link
Member

Calinou commented Oct 2, 2023

Can you reproduce this after enabling Update Continuously in the Editor Settings? (Note that this will increase CPU/GPU utilization significantly, but it can be useful for troubleshooting. To bring down CPU/GPU utilization somewhat, increase Low Processor Mode Sleep Usec to 33333 in the Editor Settings.)

@lostminds
Copy link
Author

Enabling Update Continuously does seem to alleviate the issue. The input becomes responsive again and I'm not seeing any freezes in the script editor using the Mobile renderer. If I disable it again the issues come back.

I also noted now that when the editor becomes unresponsive (with Update Continuously off) it's not getting the OS beachball-cursor indicating that macOS is considering the application unresponsive. It's also not spiking in CPU or GPU usage during the freezes. So perhaps it's some sort of update timing issue, where the editor view isn't caused to redraw when needed?

As expected Update Continuously does increase CPU usage. From 2-3% with it off to 30-35% with Update Continuously. However, that is just on one of the 10 cores, so it's for now an acceptable increase from like 1% to 3% CPU globally. I did however notice another oddity when looking at the performance numbers: With Update Continuously off the cpu usage goes down as expected when the editor goes into the background from 2-3% to 1.5%. But with Update Continuously on, it increases when the editor is sent into the background, from 30% up to about 50%.

@Calinou
Copy link
Member

Calinou commented Oct 3, 2023

But with Update Continuously on, it increases when the editor is sent into the background, from 30% up to about 50%.

This is likely due to #72401.

@lostminds
Copy link
Author

Some additional info. Now trying it on 4.2.dev6 I can see that the issue of intermittent freezing (not updating) is still present and is so in all parts of the editor, not just in the script editor as reported before. It might well have been the case all along, only I was mostly working in the script editor so that's where I noticed it.

I also tested the new ANGLE OpenGL driver for Compatibility mode (#72831) on macOS, and interestingly it has the same issue with updates stopping as the Mobile and Forward+ renderers. Perhaps this indicates that the issue is in the Metal integration somewhere, since as I understand it this Angle driver is a compatibility layer on top of Metal just like the macOS Vulkan renderers?

@lostminds
Copy link
Author

lostminds commented Oct 10, 2023

After working some more on two different projects in 4.2dev6 some additional info:

  • Enabling "Update Continuously" does make the issue much less pronounced, but it doesn't fix the issue entirely. The script editor still freezes up from time to time for 0.5-1 sec as I type or click like reported above working in projects with Mobile renderer. If I turn off "Update Continuously" the editor becomes almost unusable once it has started freezing like this, so it appears it's an issue that accumulates in some way over time. Or at least is not present when I first open the script editor.
  • In projects using the Compatibility renderer (using the old non-angle openGL driver) I do not experience the freezes in the script editor, regardless of "Update Continuously" setting.

@lostminds
Copy link
Author

As noted above the editor freezing issues also occur in Compatibility mode with the new ANGLE openGL-driver, while they don't in Compatibility mode with the old openGL driver.

In 4.2beta1 it seems the new angle driver is now the default on macOS, so you get it for Compatibility mode projects if you don't find and change this setting. Perhaps the default should be left on the old driver until these Apple Silicon mac issues are resolved, like it is on the other platforms?

@akien-mga akien-mga added this to the 4.2 milestone Oct 13, 2023
@akien-mga akien-mga modified the milestones: 4.2, 4.3, 4.x Nov 14, 2023
@lostminds
Copy link
Author

After upgrading to macOS 14 I no longer see these issues in Godot 4.2.stable on the Angle OpenGL Compatibility renderer or Mobile. It might be that this has been resolved by some Godot update or it might be that this was an issue specific to macOS 13 that was fixed in macOS 14, but either way I'm not seeing it anymore so I'm closing this issue.

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