Nuklear icon indicating copy to clipboard operation
Nuklear copied to clipboard

Crash: tooltips cause an infinite loop

Open Adamskye opened this issue 1 year ago • 2 comments

I have attached a copy of a program I am working on in its very early stages which suffers from this issue.

In the experimentation I've done with the program I've attached, the requirements for this crash to occur are as follows:

  • Have some widgets that show tooltips when hovered over.
  • Don't call nk_convert every single frame (as per the documentation's recommendation, I am only drawing frames where something changes, so I'm not calling nk_convert every frame).
  • Move your mouse between two widgets that show a tooltip on hover. In my program, the easiest way to trigger the crash is to switch between the Project and Chain pages in the bottom left.

The crash occurs in nk_convert and seems to be because nk_foreach enters an infinite loop. This causes the program to freeze, CPU usage to spike to 100% and memory usage to slowly climb.

In my program, I have patched nk_convert so that it detects when an infinite loop is starting, prints a message, then breaks from nk_foreach. While this ideally shouldn't be needed, it is better than redrawing every frame or abandoning the use of tooltips entirely.

I've noticed that somebody else has had this issue several years ago (#168) although my problem is due to tooltips and the cause of the infinite loop seems different to how he described ('next' is not set to 0). I also can provide a program that has the issue so it should hopefully be easier to diagnose.

MinDAWBroken.zip

Adamskye avatar Jul 10 '24 15:07 Adamskye

There's another thing I forgot to add. I don't know if this is relevant or not, but whenever I am moving my mouse between widgets that open tooltips, the command buffer is resizing itself a lot. Perhaps it's being corrupted in the process of being resized? I'll test with nk_init_fixed and see what happens.

Adamskye avatar Jul 10 '24 15:07 Adamskye

I believe there can only be one tooltip shown at a time, since they use the same popup identifier. Is there a way you could put some guardrails in place?

RobLoach avatar Jul 16 '24 04:07 RobLoach