Thursday, 17 January 2013

Coding again.. SleepyHead needs an update.

Feels good to functional again, I'm writing actual code for the first time in a year.
Well, I should say it feels like I'm hitting my head against the wall, but from what I remember, that's fairly normal. :)

Struggling with a couple of annoying Qt bugs on the Mac platform at the moment.

There is a memory leak in QPixmap/QImage which causes crashes in rather silly places due to the way garbage collection is done. Of all the stupid places to crash it's in the Printer code. Consistently inside of the QPrinter::newPage() function, cleaning up graphics resources. Ugh.

To work around this one I think I need to order how pixmaps are dealt with in the printing pipeline so nothing gets garbage collected during printing.

Printing works fine on all other platforms of course.

Then theres the text rendering on mac.. It's been wonky for quite some time.
Have a look at this graph section below..

D day. I didn't sleep very well back then.

It might be considered a cool graphics effect in minor doses, but all text produced by QGLWidget::renderText or QPainter::drawText on a GL device looks like that on Mac.

When I render to a Pixmap, of course it looks beautiful.. Just cropped to the left is some nice straight text, because the yAxis tickers are rendered to a QPixmap when needed to update, and drawn from an image cached as a 2D texture.

I think I might need to try a similar approach with all GL text. Maybe a Pixmap caching system or something. Might even get a performance boost across the board if I do it right.

Also greatly annoying me at the moment is when I try to render text to an offscreen image, it simply doesn't show up no matter what method I use. How rude. This one only popped up on Mountain Lion, because QGLWidget::renderPixmap no longer works. I implemented a FrameBufferObject & PixelBuffer snapshot methods in an attempt to alleviate this, but still no good. At least I've got the Pie chart pack again.

And once again, works fine on Linux & Windows. In fact runs fine in a VirtualBox running Mint Linux on this very iMac. Faster, prettier and crash free too damnit.

Well, that's what's driving me insane codewise at the moment.

These problems are much easier to deal with now I have a Mac. Previously, I nearly worked poor Jimbo (James Marshall) to death testing all my mac code.. I don't know how he didn't go insane. I'm very grateful for his help. Somehow we cobbled together some working sleepyhead goodness on Mac.

Hopefully I can get enough of this sorted to get a new SleepyHead release out soon. A year overdue, but better late than never right?

Rich Freeman has sorted out all the PRS1 60 series patches and commited the code, along with some other bug fixes.. Man am I an idiot for not handing him the commit keys sooner. His work is very much appreciated.

Anyway. Back to work for me..


  1. "Days=341 Low Usage Days = 25 (%86.10 compliant, defined as >4.0 hours)"

    Your compliance percentage seems wrong. (341-25)/341 = %92.67

  2. Hi Mark. Greetings from Canada. Couldn't find your email address, so thought I'd try reaching you via a comment on your blog. I'm a new hose head still in the trial period, and I think what you did with Sleepyhead is awesome. There's a note on the Sourceforge page that suggests you might be working on including the F&P Icon -- I'm currently using the APAP version of this machine and may end up buying it. I would dearly love to be able to track my data using Sleepyhead (for Mac!). Any chance of this happening anytime soon? Thanks! Mike

    1. The unstable builds work a bit better for F&P Icon..
      Unfortunately F&P Icon's are not the best machines for tracking sleep data.
      Both Philips Respironics System One and ResMed S9 machines record better quality data, but you've got to watch out for the "Brick" versions like the PRS1 Plus and the S9 "Escape" which only record compliance data.

    2. Thanks for your reply. I tried a Philips early in my trial, but the max humidity wasn't enough for me and my resp-tech said the Icon would fix that -- and it has. So I might be stuck with F&P for that reason. You mentioned that "the unstable builds work" for the Icon -- I'm not hugely tech savvy, so I'm wondering whether you might be able to give me a link to the Sleepyhead version you would most recommend for a Mac...and any instructions that I might need to get it up and running? Cheers, Mike

  3. Any chance a smart phone app is coming for your program ? I would love to have one for my iPhone. So would my doctor! Thanks!!!

  4. Ugh why can't I get my data to transfer from my SD card? I run Win10 and it just isn't working right.