My company, Hsoi Enterprises LLC, just released a 3.1 update to HsoiContextualServices.
Mac users, check it out! Download and use. It’s free, it’s functional, it’s useful!
Spread the word!
My company, Hsoi Enterprises LLC, just released a 3.1 update to HsoiContextualServices.
Mac users, check it out! Download and use. It’s free, it’s functional, it’s useful!
Spread the word!
I’ve been reassigned.
Still with the same company I’ve been with for many many years, but I’ve been put onto a new project. It’s radically different from what I’ve done for the past umpteen years, but it’s still writing Mac software. Yet for all the same, it’s very different. I think the hardest transition hit me this morning as I was talking with another engineer on the team. You see, for nearly two decades I’ve developed software direct for the consumer, where anyone could download it or buy it off the shelf at a store. But now, the software is written for enterprise sales and while “Average Joe” still ends up using the software, the process of making things happen, the customer I am directly responsible to isn’t Joe. It’s subtle, but it’s a different paradigm to have to work in, and I have to adjust my mental paradigm.
The project is also higher profile, higher pressure. When I was told of the reassignment (just before Christmas), I wasn’t sure. I had helped out the same project a couple of years ago and it wasn’t the most favorable experience. But time has passed, and I’m happy to see that while yes there’s still problems, there’s a true effort to improve things. The best part? The guy that’s now my boss (and then his boss as well) are very sharp. We’ve only worked together for a couple of weeks but I’m left with nothing but a solid and positive impression. They understand reality, they understand proper development process, they understand how to say “no” (very important), and they understand that their job is to enable me to do my job (getting me what I need, shielding me from what I don’t need). Even better, they understand that while there are important things to get done, we cannot have death marches, we cannot demand 60-80 hours a week every week, that people need to have their non-work lives and have balance overall in their life. This is a welcome thing and gives me hope for this assignment. Sometimes having a good boss makes all the difference in the world. 🙂
It’s been a rough couple weeks to get started, but that’s only due to being dropped into the deep end of the pool and having to swim. Just lots of little things to have to figure out, get in line and get going. But overall, so far so good. That’s one reason I haven’t been blogging much… just had other things to cope with right now. But things appear to be settling into a groove, so here’s hoping.
I am bummed that I cannot pursue working on mobile apps like for iOS and Android, but that’s not too big a worry. So long as that job maintains a healthy role in my life, I can get my mobile work in other venues. And I’m working to do just that.
Life is full of surprises. You roll with the tide. You play the hand you’re dealt, and all those clichĂ©s. I’m working to find what’s good, what’s ultimately best for me and my family. At first I wasn’t sure this move was going to be good, but it’s actually turning out to be alright. Onwards….
Daemon schism.
I posted a Facebook status message yesterday:
Well, I’m feeling more optimistic about the “daemon schism”.
which would make no sense to anyone but me and my teammate at work. Someone commented on the status update saying they had a Google fail on the phrase. So… I figured I would post it to the blog to it and claim the coining of the phrase “daemon schism”.
And for those curious, I’m splitting a daemon in two.
So we’re at a point in our development cycle where we can finally upgrade our toolset. Installed Xcode 3.2.3, using the LLVM-GCC4.2 compiler, the 10.6 SDK, and setting 10.5 as our minimum OS.
Of course now I compile code and lots of OS function deprecation warnings come up. Time to clean up the source code.
If you need to obtain a Finder label, the old-school way was to use GetLabel(). Even today we still have to use GetLabel(), despite the fact they have deprecated it since 10.5. And while they deprecated it in 10.5, they didn’t provide a replacement API until 10.6. Unfortunately this replacement API isn’t 100% workable.
1. It’s an Objective-C API, in AppKit. Specifically: -[NSWorkspace fileLabels] (and -fileLabelColors).
The old API was a pure C API so you could easily use it anywhere, and we use it in a pure C++ library. Fine. I can create a .mm file with an extern “C” function to provide my own C wrapper and mimic GetLabel()‘s API. But it’s just extra work.
2. It’s only available as of Mac OS X 10.6.
It’s not a huge problem, but it’s irritating they deprecate the old way and didn’t provide a new way until the next OS revision.
3. -fileLabels crashes.
Isn’t that wonderful? They provide a new API and the new API doesn’t work.
And it’s not like it’s any sort of difficult API to work with either. It’s just a simple call.
But how can you get it to crash? Simple. Call [[NSWorkspace sharedWorkspace] fileLabels] 3 times. The first time will be OK. The second time might generate the crash but could also just generate console messages. The third time, you should crash or certainly generate bad messages in the console. If you didn’t crash the third time, certainly on the fourth you should. But typically 3 calls and boom.
-fileLabelColors doesn’t have this problem.
Investigating it, it seems there’s something being double-released/freed/deleted inside of -fileLabels. You can turn on garbage collection and it won’t crash, but lots of ugly console messages are generated.
What also bugs me? How did this API ship with such a bug? Â Didn’t they test it? Didn’t they unit test it? Did they only test it under garbage collection? Did they write the API only for the Finder and figure if the Finder wasn’t crashing that was a good enough test to say a public API for the OS would work? Â I mean, I can understand complex bugs, I can understand how code paths can be what they are and how bugs can ship (been a professional software engineer for over 15 years). But something like this? I can’t see how this managed to get out the door.
*sigh*
rdar://problem/8301881 Seems it was also reported as rdar://problem/8084710.
So… there’s no GetLabel() replacement for me until they fix it, 10.7 if I’m lucky. Yes I’ve considered other workarounds, no they won’t work in my particular context, or with a lot of work I could get it working but it’s not mission critical and I have bigger issues to deal with.
Updated: Apple DTS wrote back saying this is a known issue being tracked under its original number: rdar://problem/7287108, which as you can see is at least the third report of the problem. So we can only hope Apple’s going to fix it, but I bet we won’t see it until 10.7 at the earliest.
The past few days I’ve been dealing with a wonderful little problem.
They’re called “named pipes“.
The main product I work on in my day job was doing some filesystem scans and would hang for some unknown reason. After much investigation we noticed the file it was hanging on was a named pipe file way down in the bowels of the system (a temporary file created by the com.apple.notify process). What was happening was well… it’s a pipe. Something in my app was opening that pipe and thus the app “hung” because it was now wanting to read from the pipe. Thing is, my app doesn’t care about pipes at all, it’s just working with files. As well, we weren’t explicitly opening the file; we would call some other OS routine and somehow somewhere in that OS function’s implementation it called open() and thus we hung.
And so, what a bear this is.
In the end we decided to check for and avoid pipe and socket files at all costs. Any means by which a file can “get into” the app, we put up a wall at the perimeter so no such files can even get in. We figure we keep them out at the wall, then we don’t have to spend lots of CPU cycles internally to constantly deal with them (tho critical code should still perform checks). Plus, since one big part of the problem is we can’t control what others do and if they might open() the file, we have to nip it in the bud as soon we become aware of the file and minimize how much “work” is done on the file in case some other function might open() the file and we risk hanging.
To check is pretty simple. Code something like this (NB: I tried using the “code” tags and less-than/greater-than signs for the #include, but WordPress’ editor seems to get confused… so I just used the “pre” tag, which isn’t quite giving me the results I want either… oh well.).
#include "sys/stat.h"
bool
FileUtilities::IsUnsupportedFilesystemItem(
const char* inPath)
{
bool is = true; // assume failure, because if we fail on such
// a simple operation something really has to be wrong
if (inPath != NULL)
{
struct stat statInfo;
int retval = lstat(inPath, &statInfo); // use lstat() instead of stat() because
// we want to minimize resolutions or other "work"
if (retval == 0)
{
if (!S_ISFIFO(statInfo.st_mode) && !S_ISSOCK(stat.st_mode))
{
is = false;
}
}
}
return is;
}
How you actually cope with it or if you consider them problems or not is up to you and your code and your situation. The key of the above is to get the file’s mode then check the FIFO and SOCK flags. If set, reject the file.
For most people, this isn’t going to be an issue or a problem. I mean, we went around for quite some time and never dealt with the issue. And in daily use, most people aren’t going to see pipe or socket files.
But it’s worth noting and thinking about. Nothing wrong with being a little defensive.
Apple changed the NSXML/CFXML implementation in Snow Leopard to use libxml. Generally a good move, but so far it appears to have caused some problems:
-[NSXMLDocument isStandalone] changed, at least in the sample code I’m using as a reproducible case for the bugs. In 10.5 the value is NO, in 10.6 it’s YES.standalone="yes", at least in the sample code, eventually causes the libxml parser to crash. Maybe not always, but if you send the sample code an AppleScript of
tell application "SimpleScriptingPlugin"
beep
end tell
the sample app will crash. Force [myNSXMLDocument setStandalone:NO] and no more crash. Or run it under Leopard regardless of the standalone setting and no crash.
It’s taken many months of investigation and going back and forth with Apple to figure out this OS bug, mostly because due to how the problem comes up we were chasing down other avenues (was this an AppleScripting problem? Still could be, at least in part.). But for now, it seems we’ve a few issues with how NSXMLDocument generates XML, how NSXMLDocument regards being standalone (and across the OS versions), and then how libxml ungracefully handles that specification. Hopefully with my further information, Apple will be able to properly remedy all of this. Yes, it’s all properly filed with Apple, so they’re aware.
I tell you. This crash problem has been plaguing me and our users for quite a while. We’ve been able to provide the users with ways to work around things, but it’s not optimal. My hope is now with this information we can provide a better solution in our code and hope that Apple will soon fix this in the OS. Finally hitting upon this last night was quite the euphoric moment. 🙂  Granted, there may still be other things to deal with for this, and I could be premature in celebrating… but certainly it’s more info for Apple towards fixing the problem, and it’s still a hopeful step in the right direction for me and the users of my product.
I realized the day was half-way over and I hadn’t written anything here.
Why?
I’ve been buried in documentation on the concept of treemaps. Lots of reading, studying of code and algorithms. It’s neat stuff.. at least to a geek like me.
I’ll be working on my own implementation soon. For what? Well… just can’t say. 🙂
I’m up late working… need music to get me through.
A little bit of boogie woogie blues from that Lil’ Ol’ Band from Texas sure gets you through.
Ye old blog has been quiet because I’ve been occupied the past few days with a fun little project.
You see, every so often Apple releases a new OS version. In this new OS version there’s always all kinds of cool technologies and goodies that makes easier the lives of us software developers. I remember when Apple released Core Data in Mac OS X 10.4 (gory technical documentation here) and what a boon that was for object graph management and being able to work with more complex data structures and files right out of the box instead of having to invent your own management system. Quite a boon. However, we (me and my team) were unable to take advantage of it when it first came out. I’m a commercial software developer and we’re driven by the market… especially what OS version our potential customers are likely to use. Thus if the new technology is only available in some particular OS version we have to wait until that’s our minimum supported OS version. That could take us a couple releases or years before that happens. Thus, we’re always way behind on adopting cutting edge technology.
I totally understand this situation from a market and sales perspective. But as a geek it always pains me because I don’t get to play with the new goodies. 🙂  By the time I get to play with them, I’m way behind the curve. In a sense that’s good because kinks get worked out, maybe Apple has updated the toolbox and filled in the holes. But it’s just not exciting to the geek in me.
Right now I’m working on implementing a new interface for the application I work on. We’re going to have to support Mac OS X 10.4 (Tiger), and that was really paining me because we’re wanting to modernize the look and feel of the app, but so long as we’re tied to 10.4 that really hampers things. Eventually we were able to come up with a strategy to give the 10.4 users one look and feel, but for users of Mac OS X 10.5 (Leopard) and beyond? They’re going to get something really new and snazzy. The cool part is I get to work with some modern technologies, like Core Animation and Core Image. I know that doesn’t mean much to you non-Mac-programmer types. Just know that a lot of the slick stuff about the Mac OS X graphical user interface comes from these. No, I don’t want to get all eye candy just for the sake of eye candy: form must follow function. But it will allow for a much more modern interface and I don’t have to wait another year or two before I can do it.
I’ve been reading documentation, experimenting in a test bed, and working to come up with a good prototype. It’s just been exciting and I haven’t had this much fun programming in a long time. I’m a kid in a candy store! So I’ve just been head-down in it. I’d love to show you what I’ve been doing but I can’t. Sorry. If you want a vague idea, if you’re a Mac user just invoke Front Row. It won’t be exactly like that, but all that behavior and effect? Core Animation, Core Image, Quartz Compositioning, all make that go.
I just bit myself, hard.
Day job has me as a software developer. I was testing out some changes to a window layout. This window allows you to configure automated tasks… so say, at midnight your computer will automatically execute whatever you told it to do. Well, I was just testing out the GUI changes but needed a task in the window so I created a dummy task. The task ended up being set to move basically every file in my home directory into my Documents folder. I didn’t set it that way, those are just all the initial settings when you create a new task. I didn’t care.. .it was just to be a dummy task for the GUI testing, right?
Only I forgot to remove the task before I stopped work for the day.
I get to my work computer this morning and about shit myself because I saw everything was gone.
Only no, it’s not all gone, it just moved some 97,000 files to a single folder.
Shit. Shit. Shit!
And the sad thing is, my Time Machine backups were turned off because last month it started to constantly choke on these particular files, and I couldn’t resolve the issue. So the last backup I have is a month old. But hey, if I had a backup from a few hours prior I could just blast it back and be done with it.
Damnit.
Well, I know what I’m spending today doing.
*sigh*