antoyo / relm

Idiomatic, GTK+-based, GUI library, inspired by Elm, written in Rust
MIT License
2.41k stars 79 forks source link

100% cpu use in Widget::run? #290

Closed emmanueltouzery closed 3 years ago

emmanueltouzery commented 3 years ago

This is my third relm application, but it's the first time I'm seeing this. It must be my fault in some way, but I'd be interested if you have some pointers or suggestions on how to try to track this one down.

I have a relm app, and when I trigger some actions, it goes to 100% cpu use. The GUI is perfectly responsive, everything works, but somehow it's burning 100% of the CPU. I put a dbg! call in the update() function of my main component, but it's not called.

A flamegraph seems to show that the CPU is going in relm::run and the gtk main loop: image

If you're interested in trying to reproduce this yourself, you can build https://github.com/emmanueltouzery/hotwire (revision 9e89745cb6ddf6046873535ce146924421d64ab5 maybe just in case) run it... you need tshark on your machine.. and it must be linux or OSX.. (tested on linux only), make a fifo file (mkfifo test.pcap), start the app, open the fifo in hotwire then after a short amount of time press "capture" to stop the capture. At that point the CPU shoots to 100% and stays there. I am launching external processes, reading from them with pipes and triggering relm events, but strangely enough the problem occurs exactly when I kill the external processes and stop dealing with these external events...

emmanueltouzery commented 3 years ago

nevermind, I got it, it was my bug. I had a glib idle callback that was going awry. I missed the fact that the rust child process try_wait would return None on the exit status if the process was ended by a signal. All ok, pebkac, I should have learned that it's (almost) never relm's fault!