aya-lang / aya

Pocket sized programs
MIT License
54 stars 3 forks source link

Fix: Aya "randomly" permanently freezes on startup when using Canvas #75

Closed BlazingTwist closed 1 year ago

BlazingTwist commented 1 year ago

Currently, when BufferStrategy::contentsLost occurs, Aya enters an infinite loop.
From the javadoc for contentsLost: 'Returns whether the drawing buffer was lost since the last call to getDrawGraphics.'
As far as I can tell, repainting does not cause the BufferStrategy to create a new Graphics instance / revalidate - so it remains true.

Removing the BufferStrategy showed no significant performance difference on my end and resolves this issue.

Alternatively, I have tried drawing to the BufferStrategy drawGraphics instead of the BufferedImage graphics, but that also gave no significant performance difference, so I've opted for the solution that removes code rather than adding some.

nick-paul commented 1 year ago

I tested on linux/openjdk and also so no major performance difference. Thanks for the fix!