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

ENIGMASH verbose_logging maxes out CPU #150

Open
angilbert opened this issue Jan 7, 2025 · 5 comments
Open

ENIGMASH verbose_logging maxes out CPU #150

angilbert opened this issue Jan 7, 2025 · 5 comments
Labels
bug Something isn't working

Comments

@angilbert
Copy link

angilbert commented Jan 7, 2025

Describe the bug
ENIGMASH verbose_logging prevents game play

Reproduction Steps

  1. Load https://david-pfx.github.io/PuzzleScriptNext/src/editor.html
  2. Load ENIGMASH example game
  3. Start game and confirm movement is possible
  4. Click on the button to enable verbose_logging, click back on the game
  5. The game stops responding to input

What did you expect would happen?
verbose_logging works - as it does in it's original fork:
https://jacklance.github.io/PuzzleScript/editor.html?hack=cfdcc6e23f1fb3e9de2fd42fafaf4d4c

OS & Browser version, desktop/mobile
MAC/Desktop/Chrome (also tested Firefox)
Dev and Stable release behave the same

Depending on the browser you may eventually see a pop-up similar to this...
Screenshot 2025-01-07 at 16 58 24

@angilbert angilbert added the bug Something isn't working label Jan 7, 2025
@david-pfx
Copy link
Owner

  1. Click on the game.
  2. The game now responds to input.

It's a kind of known bug, but the bug is about loss of focus, nothing more. I've known about it, but never got around to doing anything about it.

@angilbert
Copy link
Author

That isn't the explanation here, but I retested it, to be sure. You can reproduce the issue a different way, by adding "verbose_logging" to the prelude first. Then save and run - and hit X to continue past the credit message. The screen then goes blank and the browser appears to hang.

Screenshot 2025-01-08 at 10 23 14

After a long pause the game eventually appears.
In the browser console you can see an event handler takes 93 seconds to react:

Screenshot 2025-01-08 at 10 20 48

@david-pfx
Copy link
Owner

I agree, I saw that too. The 'prevents game play' is incorrect, but horribly slow is a better description. My machine is a high end gaming laptop, and it appears to take 100% CPU on one core for nearly 30s. Enigmash is slow at the best of times, and verbose logging shows over 3000 rule applications.

My guess is one could put a lot of work into this and improve the speed by 20%. I don't think that's a priority, but getting the focus to work right probably is worth it.

@angilbert angilbert changed the title ENIGMASH verbose_logging prevents game play ENIGMASH verbose_logging maxes out CPU Jan 8, 2025
@angilbert
Copy link
Author

angilbert commented Jan 8, 2025

I've adjusted the title. Yes, I agree, that's a lot of rules. I did wonder if local_radius was broken, but comparing the verbose_logging from a single player move (step left) on the two forks side-by-side I see a comparable number of rules are triggered. That said PSNext does trigger a few more late rules, which is curious. Why should more rules trigger in PSNext? Both sources are 2580 lines - so I assume identical.

Here I am comparing...
https://jacklance.github.io/PuzzleScript/editor.html?hack=cfdcc6e23f1fb3e9de2fd42fafaf4d4c (left)
with https://david-pfx.github.io/PuzzleScriptNext/src/editor.html (right)

Screenshot 2025-01-08 at 14 18 08

Question... Is local_radius actually working at all? On either fork?

@david-pfx
Copy link
Owner

That's weird. I'll have to look into what those extra rules are.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants