Sunday, December 24, 2017

App Nap in High Sierra

Update: 1/5/2018 It turns out this problem had nothing to do with app nap at all. It’s a thread contention issue in the screen drawing code in High Sierra and there is a very nasty workaround you can do to get it working. I’ve written about it Here


There is an undocumented change to how App Nap is handled in the latest build of the High Sierra operating system. In past OS versions the operating system actually believed you when you said you were executing a user initiated process and let your app continue to operate as normal even when the user wasn’t using your app. That seems no longer to be the case with High Sierra.

App Nap is a great idea overall. If your app isn’t being used it can be put to sleep and we can not waste the battery or the power to keep it doing all it’s interface animation and what now while the user isn’t using it. Unfortunately apps like my day job at XTension need to remain responsive to incoming data or connections even when the user has been absent for months. In the past this was no problem! MacOS was efficient and my app managed it’s memory carefully and didn’t leak and so for 6 months or more you could run in the background and keep doing all you needed to do.

That is no longer the case with High Sierra. If the user isn’t there and the screen goes to sleep then ALL the user apps will go to sleep. Even if they have done what apple suggested and register a “user initiated action” that should continue to work even while the user wanders off. High Sierra seems to decide that if the user has let the screen go to sleep then no user tasks need to be of high priority. This is remarkably frustrating as there are definitely apps that want to run while there is no user sitting at the machine.

The officially documented way to disable app nap does NOT work with High Sierra.

The only work around that I’ve been able to figure out is to disable putting the screen sleep. You can do this manually in the energy saver preferences just set the screen to never go to sleep. If you’re doing the official apple way of doing things then you can set the disable Idle Screen Sleep flag when you create your action.

Or you can just tell your users to set their energy saver preferences to never shut off the screen... This is a completely undocumented change that makes a huge difference to us developers of apps that run without the user sitting in front of the machine. I am very frustrated.

Sunday, October 8, 2017

SSL Secure Communications in XTension

My day job remains, happily, the Home Automation software XTension. We’ve managed to avoid creating a “cloud” for ourselves and yet have to weather lots of questions about data security. Especially for the Web Interfaces that we have customized for mobile clients or desktop clients. The truth is, if you’re willing to write a few numbers on a card in your wallet you can verify the serial number of the certificate from a public computer, and if you’re connecting from your own laptop or phone then your keychain will do that for you and it’s trivially simple to know if someone is performing a man-in-the-middle type attack despite the horrible brimstone and everybody is going to die warnings from your browser. Secure Communications in XTension

Friday, September 22, 2017

cMediaFile a Xojo class for serving video or audio files to Safari on MacOS and iOS

My day job is as a developer for XTension a Mac based home automation system.

Some years ago something changed in Safari and it stopped playing the video clips that XTension saves off in response to motion or other perimeter violations. I could never get it to work on iOS either. This was remarkably frustrating to have to tell people that to view the video archives in the Web Interface they had to use a different browser. It continued to work just fine in Chrome and Firefox. I thought at first that it had to do with using a self signed certificate but it turns out that Safari absolutely requires you to support the Range header and to properly reply. The other browsers were happy with my response of the entirety of the file even though they also initially ask for a smaller range of bytes. Safari was not happy with that and flatly refused to load the files at all unless I supported their range request.

The Web Remote and Mobile Web Remote in XTension are developed with Xojo and the built in webFile class does not support range requests. Since figuring this out I’ve been able to implement a replacement class that does support them. Should any other Xojo developers need to serve up video or audio files to Safari or Mobile Safari they are free (as in beer) to use the cMediaFile class and even to improve it and make new submissions at the github repository.

Download the class and example project: https://github.com/PlanetaryGear/mediaFile

Here’s an example of XTension’s Video Archive page now working again in Safari!


Friday, August 18, 2017

Veneered Mantle

We recently “finished” some small additions to the house. A 2 month estimated project that took 7 months to complete. Then it was my turn to start working on the parts of the project that I wanted to do. That has also stretched out a bit in time, but at least now my long suffering wife knows she couldn’t get it done any faster by hiring an actual contractor ;)

We both hated the family room fireplace (and don’t even get me started on the living room fireplace, that is another blog entry and is now completely gone) it had a real flue at least, unlike the living room “fireplace” but was such a small firebox that once you put 2 logs into it the fire didn’t even start until it was up above the top of the hood. It was built into one of these great mantle/surround things. They look nice from a distance but up close they are just a bunch of particle board moldings screwed together, really clunky and not very nice or useful at all.

As part of the addition we had a hearth built and what turned out to be a very nice faux stone chimney made. I’m really happy with the way the stone turned out but I wanted a nicer mantle than what they would give me. Offers of a nice piece of reclaimed lumber or something doesn’t really fit with what I wanted so I asked then to just give me a 2x4 cleat across the stone onto which I could attach a mantle I could build myself.

The wiring from the outlets along that wall also ran through that space so I was able to bring it up through the mantle and mount another outlet on to what will be inside the mantle for plugging in lamps and clocks or anything else without having a cord falling over the side which was important to me as that always looked horrible on the existing mantle.




The box is pretty simple. Half inch plywood with an inside system of supports to make sure it stays square and strong. I drilled them out in the middle though so that any wires I ran to anything could get back and forth. The cut out on the top will be removable panels with some holes drilled for cords to come through up where you need them.

Then I went to test fit the box only to discover that the 2x4s they put up were not really alined with each other and weren’t actually straight either. Several hours of messing around with an oscillating saw and a lot of sawdust later and I had straightened up the cleat good enough for the box to fit snugly over and let it get right back against the stone. In retrospect I should have disconnected the wires and just taken off their cleats and added fresh ones of my own but somehow that didn’t occur to me at the time. The rule is doing it wrong takes a lot more time and effort than doing it right ;)



After trimming and shimming the cleats it fit very nice and tight and I only had to take a cold chisel to a couple of stone corners to make it fit fully into the stone face. I ran into another problem which you can see in the first picture above. The electrical wire was getting crimped by the support blocks and keeping them from being flush with the cleat. I could have removed the wire and pulled it through the supports, but I wanted to be able to take off the mantle in the future if the veneer failed or if something happened that I needed to change or fix it. So back to the oscillating saw and I cut some notches into the cleat to allow the wire to safely snake around the support blocks. This removes some of the structure of the thing since they won’t be pressed against the cleat, but it turned out that didn’t matter, it’s plenty strong even before I screwed it into the cleat from top and bottom. Now that the box was complete and fitted it was time to decide about the veneer.

I’ve been wanting to invest in the tools to do real veneering for a long time. Since this was a Significant Other approved project I was able to justify the purchase of a lower end vacuum pump and veneer press. Unfortunately the mantle box is a little longer than 4’ and I only bought the 4’ veneer compression bag. Instead of just buying a larger bag and waiting for it to arrive I decided to go with regular wood working glue and lots and lots of clamps and cauls.

I ordered some beautiful Redwood Burl veneer from VeneerSupplies.com along with the bag and vacuum pump. When it arrived I realized I had another problem. It would have to be flattened in order to properly adhere to the workpiece. For this at least I was able to use the vacuum bag and veneer press. The internet has many products you can spray on the veneer to soften it for flattening and many recipes for DIY flattening and much discussion claiming its pressure or temperature or chemical that you use that is better. It was actually hard to choose a mode of working on this that I knew would work given how many ideas are out there and how adamant the various players are. I ended up using a formula of mostly water with a small amount of glycerine in it. The glycerine to soften the wood, but not so much that it would affect the staining or finishing or glue up process. I gave the pieces a gentle spray, packed them between sheets of masonite and loaded them into the vacuum press overnight.

What came out was beautiful and flat and ready for book matching and layup. I gave it a quick wipe down with some isopropyl alcohol to remove the surface glycerine as my tests with small pieces showed that really did mess up the absorption of the oil finish if I didn’t do so. This was also a very oily veneer which would affect the adhesion of the finish without doing this. Acetone would probably have worked better.

I’ve never done anything with veneer before at all so this was an adventure. Instead of cutting the pieces to make them line up perfectly I used fine sandpaper on a wooden block. Taking 2 pieces of veneer that matched and folding them over so the two edges that would match up were together. Then clamping that between 2 pieces of wood without about half an MM or more if necessary to get the angle right, sticking out. Then gently used that sanding block to sand them down flat with the wood they were clamped between. When they were taken out they would open out and fit together perfectly. Again without all the proper tools I didn’t bother with veneer tape, just blue masking tape to hold them together as I prepared them to be glued to the box.

Lots and lots of clamps and cauls later I was really happy with the result. Don’t look too closely at the corners and edges that got dinged. This was a very fragile veneer. I hid most of those spots during finishing either with a little spot of veneer roughly matched or some appropriately colored stain.
   
















The final veneer before finishing really looked nice and made me very happy!

First a coat of Linseed oil to really bring out the color and figure. It darkened up a little more than I would have liked, maybe danish oil next time which I think has less of a darkening effect from what I’ve seen. Perhaps I didn’t experiment with different finishes on this enough before jumping in, but it still turned out fantastic.












Thursday, April 13, 2017

The Makerbot is dead, long live the Makerbot! And a new Monoprice Select Plus 3D!

I actually use my 3D printer for printing small runs of plastic parts. They go with the Smart Meter Reader Kit and some others for kits that are not shipping yet as of this writing. They all connect to my day job which is XTension. Last week I needed to print another smart meter sensor mount for someone and found that my Makerbot was no longer recognized over USB even though it seemed to be working OK from the front panel. So the next thing I tried was to get it to print off it’s CF card and it wasn’t able to find anything on the car either even though it had just printed from that card a few months ago. Not having time to try to troubleshoot the boards myself right now I decided to upgrade to a new printer! Enter my new Monoprice Maker Select Plus 3D Printer!

Costing less than a quarter of what the Replicator cost me several years ago and supposedly producing better prints. I’ve only had it for a few days now, but I’m generally hopeful that it will be a good printer and do what I need and for under $400 you can’t beat the price for anything with that build volume and a heated bed. Putting the hardware together was very simple but the software is a huge problem. As with most things in the inexpensive range of open source stuff it’s a nightmare to figure out how to use the thing. The documentation Monoprice is shipping with recommends Cura as the slicer and control app to use. Unfortunately their docs are enough versions behind the current Cura release that there is not a single window or screen in the app that looks like what they show. Every single option is in a different place and many of them no longer exist in the app at all. Trying to slice a model for it was very frustrating on that first day. It did print the test files that come on the CF card very nicely though, as good as my makerbot after lots of tweaking and fiddling with settings and several failed prints as part of the tweaking process. So I was still positive this was going to be a useful printer if I could just figure out the software. 

There is an old version of Cura included on the CF card, but only for Windows. Why would they customize an old version of the app rather than supply the files so that you could more easily add the printer to the latest version? I have no idea. But it’s useless to me on this Mac and it’s becoming more and more useless to windows users as it gets older and older compared to the current release of Cura. 

There are a lot of older web articles explaining how to extract the profile information from the models that came with on the card, but this is also no longer available in the newer versions of Cura. Finally the best resource I found talking about it is at 3dprinterwiki.info This is a fantastic site! The monoprice printer is a re-branded Wanhao duplicator I3 plus. On that site is a link to the slicing profile info that you need to know in order to make really nice prints on it. The same settings that were used in the demo files that ship with the printer that worked so well. The out of date instructions imply that you can somehow extract the profile info from the gcode files, but I could not find that feature anywhere in the current Cura versions so you’ll need the link from the wiki to get that setup.

Everything you need to know is on that site but you’ll do a lot of reading to get to it. 

more info here too on the machine settings
http://www.makehaven.org/i/647

Additionally there is little point in trying to get Cura to print to the device via USB. It says it’s theoretically possible, but I was unsuccessful in making it notice the printer was connected even after a large amount of screwing around with different usb/serial drivers and settings in the Cura configuration files. I would stick to using the CF card and sneakernetting it to the printer. This also means that if you have a software crash or a power failure or just want to restart your computer or wander off with it you don’t have to leave it on the desk for however many hours the print is going to take.

The sticker on the heated bed in this printer works very well for PLA, but I’ve just received my first upgrade in the form of a glass plate and will be attaching that and resetting the Z Axiz sensor soon.

A New XTension Version

Just news from the day job. XTension is a home automation and security program for the Macintosh and today we released a maintenance release fixing a few usability issues in the new unit list controls that we added in the last version. Also adding a few minor features like Bonjour/mDNS/Zeroconf support for the JSON/web server so that your IOT devices can more easily find where it’s running and on what port to report their status changes to.

http://MacHomeAutomation.com/
.code { background:#f5f8fa; background-repeat:no-repeat; border: solid #5C7B90; border-width: 1px 1px 1px 20px; color: #000000; font: 13px 'Courier New', Courier, monospace; line-height: 16px; margin: 10px 0 10px 10px; max-height: 200px; min-height: 16px; overflow: auto; padding: 28px 10px 10px; width: 90%; } .code:hover { background-repeat:no-repeat; }