kliment / Printrun

Pronterface, Pronsole, and Printcore - Pure Python 3d printing host software
GNU General Public License v3.0
2.38k stars 996 forks source link

Pronterface hangs on Mac with lots of debug from the firmware #353

Closed drf5n closed 10 years ago

drf5n commented 11 years ago

If I'm using Teacup with PID debugging turned on (M111 S1 will produce a couple hundred lines per second) Pronterface slows and then hangs and then must be forced to quit. Pronsole can watch the debug process for minutes without incident.

I can keep Pronterface running if I File/Clear Console every 10 seconds or so, but then it slows and then stops after 30-40 seconds.

I think it might be that the logbox gets too big for a wx.TextCtrl and then causes problems.

sbliven commented 11 years ago

Duplicate of #292 ?

drf5n commented 11 years ago

Yes. It is the same issue. After I posted this, I noticed I had commented on the other issue. Here, I noticed that I could postpone the hang by clearing the console, so I'm pretty sure it has to be in something like the logbox wx.TextCtrl code.

iXce commented 11 years ago

As far as I know, wx.TextCtrl does /not/ buffer more than a few KB of data, unless the OS X implementation is different. However we had an internal log which was unbounded, which I should have fixed in commit 16208ae. Can you try ? If not, I'll dig more on the wx.TextCtrl side (as the clear console button should only clear the TextCtrl and not the internal log)

iXce commented 11 years ago

Any news about this one ? If not, I'll close it within a week.

drf5n commented 10 years ago

Sorry it's taken so long to get back with feedback. I still get the hangs with the current github revision (2014-03-15, https://github.com/kliment/Printrun/commit/36eff4ab1f33da4774d2a97403674b7500fbae5c ). I can still prevent the hang by with repeated "Clear console" and I can recover from the hang by connecting with pronsole, cancelling the debug output (M111 S0), disconnecting in pronsole, then "Clear output" in Pronterface, and then reconnecting in Pronterface.

The size of the apparently full text in the box after the recovery by wc is 12953 lines and 530135 characters.

This ugly hack seems to make it not hang:

diff --git a/printrun/pronterface.py b/printrun/pronterface.py
index c469cc3..dbfa79a 100644
--- a/printrun/pronterface.py
+++ b/printrun/pronterface.py
@@ -1333,6 +1333,8 @@ Printrun. If not, see <http://www.gnu.org/licenses/>."""
                 wx.CallAfter(self.graph.StopPlotting)

     def addtexttolog(self, text):
+ if self.logbox.GetLastPosition() > 20000:
+         self.logbox.Remove(0,self.logbox.GetLastPosition()-10000)    
         try:
             self.logbox.AppendText(text)
         except:
iXce commented 10 years ago

Okai, so this is really an issue with the TextCtrl implementation. The workaround might be acceptable then :) Let me check the TextCtrl implementation on OSX.

iXce commented 10 years ago

Looks like a decent workaround ! Integrated. Thanks for the report !