Welcome to the first anniversary edition of “What I…”. I can’t believe it’s been a year already, it feels so much shorter.

Another busy month comes to a close.

The bulk of this month obviously went into Yoink 3.2, but with a release also comes all of this other work you need to do – update the Mac App Store page, perhaps add new screenshots, think about keywords, update the website, write a blog post about it or create a newsletter mail… Release-days are busy. Long story short, after the work is done, there is so much more work to do…
Aside from all of that, though, I’ve also been trying to learn and get into Auto-Layout, which I’ve been neglecting far too long only to now realize it’s the most beautiful thing in the world, when it comes to localizing and internationalizing your app. It’s a godsend.

I also had to tip my toes into PHP again. I’ve had to do that every now and then (way back when I was still selling flickery outside the Mac App Store and had to communicate with PayPal somehow), so it’s nice to get back to it and work in a language other than Objective-C for a change. (ahem. Swift. ahem. I’ll have to get to that as well. Any day now.)

Let’s get into what I…

… Did

Finished up and released Yoink v3.2 (website, Mac App Store)
After a long time working on it (I checked, I last updated Yoink early in September 2015), I was finally able to give the green light for the latest update to Yoink.
If you follow this blog, you know what I’ve been through with this release 😉
I blogged about what’s new here.
As far as I can tell, it’s been very well received (I might do a short blog post about some coverage of it later).
Here’s a very nice review of the new version on the Mac App Store:

Review of Yoink 3.2 on the Mac App StoreA recent review of Yoink on the Mac App Store (powered by launchkit.io)

I changed a couple of things regarding Yoink’s Mac App Store page.
I read about ASO (App Store Optimization) and realized I was wasting a perfect opportunity for additional keywords: The app’s display name (the name that appears on the Mac App Store). Up until now, it was just “Yoink” – so I changed it to “Yoink – Simplify and Improve Drag and Drop”. That gives me the keywords “drag” and “drop” for free, so there’s more place now in the actual keywords field.

Furthermore, I gave Yoink much-needed new App Store Screenshots.
This is what screenshots looked like before…

Old Mac App Store Screenshot of Yoink

… and this is what they look like now:

New Mac App Store Screenshot of Yoink

There were a couple of things important to me:

  1. Readability. I don’t know what I was thinking with the old screenshots there
  2. Yoink being displayed running on a Mac.
  3. Improved wording
  4. Kind of a vanity thing, but I wanted to have ESSPurple (my “company color”) in the shots.
I’m pretty happy with how they turned out, especially that they’re cleaner and less busy. I’m not sure what I thought when I created the old screenshots. Those mountains sure draw a lot of attention.

Fun fact: Because so much changed between Yoink 3.1 and 3.2, I actually exceeded the limit of 4,000 characters in iTunes Connect’s “What’s New” section – by 2,000 characters. That was the entire “Bug fixes” section, so it had to go, and got replaced with “Numerous Bugfixes”. There were about twenty, which I’d have loved to list, just to give a complete account of what changed.

Apple’s review process was surprisingly painless (as in, no rejections) and quick (as in, two days. Two!)
I submitted the update early (on April 13th), to make sure that, if anything cataclysmic happened, I’d have enough time to sort it out. Thankfully, that extra time wasn’t needed.
What made me a little concerned was that I introduced two XPC services in this release (one that looks for any Force Touch capable devices and another one that handles newsletter subscriptions).
I thought especially the Force Touch XPC service might give me some trouble.
So I painstakingly explained which sandbox entitlements I used and how, which I think helped a great deal in getting this update reviewed as quickly as it was (plus, lower review times seem to be a trend recently – currently around two days), with no rejections.

Regarding press releases, I’ve made it a habit to send them out a week early with an “embargo”, to give members of the press time to first of all get to the email in time (as they surely receive tons of mails every day) and to prepare something if they liked it. I updated the press kit (nothing major, just added the new screenshots and a .webloc to the Usage Tips page).

Come release-day, I first released the app on iTunes Connect (it always takes a little time for the App Store to “realize” that the update was released). In the meantime I posted the blog entry I had prepared earlier for the update and when I thought the update was populated on the Mac App Store, sent out the newsletter to my subscribers (if you’d like to, you can subscribe here) and started talking about it on twitter and in my Facebook group.

All in all, I’m very happy with how the release went. It can always be better, but I can not complain.

Updated Yoink’s Website and Usage Tips Page (website, usage tips)
Along with the app, I wanted to update the website as well. Mainly because I wanted to mention Force Touch, and partly because the more you scrolled down on the website, the more of a mess it became.
Starting at the top of the website, I decided to move the customer and press reviews down a little. While I think they’re very important, as they show what real people using the app think about it, they’re not as important as an intro to what the app does.
Before (again coming down from the top), you had Yoink’s icon with a short blurb, the download and purchase buttons and right below that, selected reviews.
On the new site, what you see below the buttons is a nice “photo” of Yoink running on a MacBook Pro (with a background image that’s one of the complementary colors of purple to draw attention to it). Then come the reviews.
So now you have an intro to the app and below that, how nice people think the app is. I believe that works much better.
Furthermore, I tried to condense the site a little, it kind of felt like an endless scrolling website before, without real structure, almost like “what else can I quickly paste randomly on this website I think might be important”?
So I introduced “boxes”, like this one, in an attempt to give a little structure to the site:

Yoink Website Box

Previously, the features listed here were in a long list with a couple of screenshots and gifs, not at all attractive. I’m not a hundred percent happy with this either, but if you ask me, it’s way better than before.
I’ve applied the same “boxed” approach to the tips page, in order to condense it a little (it was also a long list) and give it a fresher look, in line with the app’s main page.
Lastly, I’ve added a newsletter signup form to the bottom of the page (and to the top right “Quick Links” list), because #GrowthHacking.

Learning Auto Layout, with SiriMote (website)
As I said in the intro to this post, I’ve been pushing off getting to know Auto Layout for far too long – though, in my defence, my apps have all been running with NSView’s auto resizing and I didn’t really have the time or need to switch.
Anyway, now that I have started using Auto Layout (in SiriMote, just because it’s my smallest project and it doesn’t have anything too complex, UI wise), I don’t want to go back.
There’s so much magic happening behind the scenes here:

SiriMote AutoLayout Test (Short string)SiriMote AutoLayout Test (long string)

Now I only have one xib (because I also switched to base-localization instead of having one xib for each language) and when I change a string in a language, I don’t have to go through every UI element in the xib and move things around to make it fit – Auto Layout does it for me. Ah, the future. It’s so nice.

I’ve also gone a step further and tried animating the window solely by changing the constraints, not manipulating the window’s frame directly.
So far, it works and – after some work, as I came to understand constraints better – now looks just like before.

Featured in LaunchKit’s Launch Therapy Issue #8 (issue #8)
My post on getting featured on the Mac App Store in the “Get Productive” promotion made its way into launchkit’s excellent newsletter, Launch Therapy.
Having that kind of a reaction to something I wrote is very encouraging, and I hope I can improve my writing in a way that it gets featured even more 😛

BeautifulPixels ScreenFloat Sponorship (beautifulpixels)
After having sponsored BeautifulPixels for a week with Yoink, I ran another campaign, this time featuring ScreenFloat.
Yoink performed slightly better, but I attribute that to my inability to clearly communicate what ScreenFloat actually does. I’m trying to improve, but I struggle with it a fair bit.
“Floating screenshots” just doesn’t make clear how convenient it actually is, or doesn’t imply what can be done with it.
I must find a nicer way to describe the app.

Scripting in PHP
As you may know by now, I’ve started a newsletter. People interested in it can subscribe through the website, or through my apps’ about windows.
What I didn’t think of beforehand, though: what if I need to change the newsletter service I’m using, for whatever reason? Or what if the API changes? I’d need to put out an update just to make the app use the API of the new service.
That’s kind of inconvenient. So I decided to write a small php script that talks to the service’s API, put it on my own server and make my apps communicate with that php script instead of with the service’s API directly.
Now I have the freedom to switch the API behind the scenes, or update the API calls, should they change.
Still, some of the damage is done already, since I didn’t think of this before releasing Yoink 3.2, for example, or SiriMote. I’ll still have to update those apps once to make them use my php script, but from then on, it should be smooth sailings.

Adding more Character and Branding to my Applications
After adding some color and character to my website and about windows (see here), I decided to use ESSPurple a little more.
For all my apps (besides Transloader), I’m offering demos. When the trial period is over, an alert panel is shown. But that’s just lazy, and potentially not nice to look at.
That got me thinking: Perhaps it would benefit from some color. This is what I came up with:

New Trial Over notice in my applicationsYoink 3.2’s Demo Over Notice

And, as I wrote above, the Mac App Store Screenshots also received an update.

… Didn’t Do

Register for WWDC (apple)
I’ve been thinking a lot about whether or not I should apply for a ticket to Apple’s World Wide Developer Conference this year. After all, it is the best place to meet people in the industry and community. It’s also very valuable to be able to talk to Apple’s developers directly.
Even if I didn’t get a ticket, there’s usually a lot of other conferences and get-togethers around during the time of the conference.
But the flight alone would cost upwards of €1,000, and the hotels in San Francisco are insanely expensive. There’s no way I could justify that expense, to be honest.
I think Apple should announce WWDC earlier, not a ~month before the event. The beginning of the year would be good – flight tickets would cost less and it might even help with hotel prices.
Who knows, maybe next year.
Alternatively, I’m now thinking of attending one of Apple’s Tech Talks, either in London or somewhere in Germany (because they don’t have them here in Austria). My first choice would be London, just because I love it there. But I’ll make it dependent on who goes where. If more people go to Germany, then that’s where I’ll be going as well.

… Blogged About

Developer Tip: How to Install the Ink System Preferences Pane Without a Graphics Tablet (blog post)
In some cases, you need to test your apps with OS X’s built in handwriting recognition (called Ink) enabled.
This post shows you how to enable it, even if you don’t have a graphics tablet handy.

Under-the-Hood Improvements in Yoink 3.2 (blog post)
A technical blog post about what changed under the hood in Yoink 3.2, showing how I was able to improve the app’s performance and memory usage.

… Downloaded

Safari Technology PreviewSafari Technology Preview (apple)
A good alternative to the webkit’s nightly builds, as it also includes upcoming browser features, not just the latest version of the browser’s foundation, WebKit.
It’s amazingly fast.

TelegramTelegram (mac app store)
I was invited to partake in a survey, but it had to be over Telegram, so I downloaded it. Alas, for registration, they wanted my phone number, so in the Trash it went. Sorry, Telegram, nice try. That’s why I don’t use What’sApp, either.

Shade App IconShade (mac app store)
Quickly hide files on your desktop. Useful when you need to create screenshots or videos of your Mac.

Miitomo App IconMiitomo (app store)
A fun little “game” by Nintendo where you answer questions about yourself and friends.

Disney Crossy Road App IconDisney Crossy Road (app store)
You know Crossy Road. You know Disney. A perfect fit. Fun game.

… Read

Apple Developer Insights Webpage (apple)
Success stories of successful developers.

The iOS App Marketing Strategy Guide (apptamin)
“Everything we know about launching and marketing an iPad or iPhone app.”

5,000 Developers Talk About Their Salaries (freecodecamp)
Interesting insights. “The more you work, the more you get paid.”

How to Write App Descriptions That Sell (yalantis)
“There are three components of an app’s ‘definition’: its Name, its Description in the marketplace and Screenshots.”

Like It Is: Bob Dylan Explains What Really Killed Rock’n’Roll (cuepoint)
“… the genre was being commercially segregated, on the sly, into white (British Invasion) and black (soul) music by the (WASPy) establishment.”

Developers Switch to Subscription Prices to Move From a Consumer Audience to a Business One (macworld)
More and more apps seem to be switching to subscription-based business models. I wonder if it’s more sustainable than the “classic” approach of selling software, considering the backlash it caused for TextExpander’s developer Smile Software, for example.

Humanity's Extraterrestrial Origins Book CoverHumanity’s Extraterrestrial Origins (amazon)
An interesting, maybe amusing look at life from the other side of science. I wouldn’t take this at face value, but it makes you think for sure.

… Listened To

Core Intuition Podcast (website, itunes)
Lately, I’ve been enjoying the CoreInt podcast.

Leo Laporte Interviews Bill Atkinson (youtube)
About the early days of the Macintosh. A wonderful interview.

… Watched

FAN Movie PosterFAN (imdb)
Shah Rukh Khan’s latest movie. One of his finest roles, acting-wise, in our opinion. What’s unusual about this bollywood-movie is the absence of dance-numbers and songs. It’s all about the story this time 😉

The Jungle Book Movie PosterThe Jungle Book (itunes)
The live-action adaption of the Disney animated classic.
My girlfriend and I enjoyed it a lot, though we both thought the songs felt out-of-place and didn’t fit with the movie. They should not have included them to make this a film in its own right. And even then – nothing beats the classic!

… Ate

Vegetable Enchiladas with self-made Potatoe ChipsVegetable Enchiladas with self-made Potato Chips

… Went to See

Sadly, I didn’t have a lot of time this month to go out and see places (though my girlfriend and I did go to see my Alma Mater, the University of Vienna, to see what’s new 😉 ), so please accept these cute photos of my girlfriend’s mom’s adorable dog, Lucky, instead.

Dog YawningDog staring

Eternal Storms Software Logo

– – – Do you enjoy my blog and/or my software? – – –

Stay up-to-date on all things Eternal Storms Software and join my low-frequency newsletter (one mail a month at most).
Thank you 🙂

Read more

Yoink Mac App Icon

I’m happy to tell you that today, Yoink 3.2 is available for download from the Mac App Store.
It’s a free upgrade for everyone who’s purchased it before.
You can download a 15-day trial for the app here, even if you’ve tried it before.

What Is Yoink?

Yoink simplifies and improves drag and drop on your Mac.

Simplify.

It simplifies drag and drop by providing a temporary place for files you drag, so you can navigate more easily to the destination of the files.
It’s especially useful when trying to move or copy files between different windows, Spaces or (fullscreen) applications.

Moving a file with Yoink

When you start moving a file in Finder, or app-content like an image from a website, Yoink appears at the edge of your screen, offering a temporary place for you to drag the files to.
Without having to keep the mouse button pressed, you can now get to the destination of your file quicker and easier.

Improve.

Drag and drop is improved in several ways, including:

  • Collect multiple files from different locations you’d like to move to one destination without having to go back and forth
  • Split up a multiple-files-drag so you can move files to different places without having to go back and forth
  • Copy files to multiple locations more efficiently

Customize.

You can customize Yoink’s behavior so it fits in perfectly with your workflow. Aside from having to option to show it at either edge of your screen (at the top, center or bottom), you can set it up to only appear when you drag files to the edge of your screen or to appear directly at your mouse cursor when you start dragging, making drag and drop even faster.

Yoink appearing at the mouse cursor

For applications where you don’t need Yoink, add them to a “blacklist”, so Yoink doesn’t interfere with your work.
A keyboard shortcut (by default, F5) lets you manually show or hide it, should you need it anyways.

What’s New in Yoink 3.2?

Force Touch Support

Force Touch in Yoink allows for quick actions, i.e. selecting all files, revealing files in Finder, QuickLooking files, splitting up Stacks and pinning files to Yoink, all available with one Force Click.

Yoink's Force Touch Preferences

For instance, Force Touch makes dragging out all files at once a much nicer process than before. Force Click onto one file and all are selected. Ease up one pressure level and start to drag, and you’ll drag all files instantly.
Additionally, Yoink can give you haptic feedback when dragging to it, so you know when you’ve entered Yoink’s window with files.

Deletion Warning

Yoink does not keep a copy of the files you add to it behind the scenes, so it’s important for users to know that if they Trash a file that’s in Yoink, it will be gone if it’s deleted.

Trash warning in Yoink 3.2

This one-time-per-app-launch warning notifies the user about what’s going on.

UI Enhancements

In previous versions of Yoink, when you moved your mouse cursor over a file, this happened:

Yoink 3 Icon Behavior

Some users felt that this results in a moving target (as the icon moves away), and that is definitely a bad user experience (in my defence, I didn’t think of it creating a moving target, because not only the icon, but also the background can be dragged).
Anyway, point taken, I’ve changed it to a simpler, and in the end calmer, animation:

Yoink 3.2 Icon Animation

What you can also see in the two GIFs above, I’ve changed the lock icon so it’s easier to tell if a file is pinned to Yoink or not.
Speaking of the lock, I’ve added a new animation that will let you know that the file can not be removed because it’s currently pinned to Yoink:

Yoink Lock Icon Jiggle

Further Improvements

  • File paths can be copied from Yoink’s contextual menu
  • Reduce Motion Setting
  • Text snippets can now contain images
  • Performance and resource management improvements when accepting files, dragging files out, clearing all items, splitting up stacks, opening the “Open With” menu
  • When Yoink is shown on a different screen than the mouse cursor, the keyboard shortcut (by default, F5) summons it to the screen of the cursor
  • Yoink reflects changes in the Finder’s “Show all filename extensions” setting
  • Mails dragged from Yoink work again with all applications. To create an event in iCal from a mail message, keep the option-key pressed as you drag the mail out of Yoink
  • When a file is re-saved in Finder, Yoink updates its QuickLook Preview Icon
  • When a snippet is added to Yoink, it has a proper filename instead of “Snippet”
  • And many more improvements and bug fixes throughout the application

Pricing and Availability

Yoink 3.2 is available for purchase on the Mac App Store for the price of $6.99 / £4.99 / €6,99.
It is a free update for existing customers of the app.
You can download a free, 15-day demo version here, even if you’ve tried Yoink before.
Yoink runs on Macs with OS X Lion 10.7.3 or newer. OS X Yosemite or newer is recommended.

If you’re interested in writing about Yoink, you can download the press kit here, which contains screenshots, links to a short video and further information. Promo codes are available to members of the press at press (at) eternalstorms (dot) at.

Yoink Usage Tips

To get the most out of Yoink, I’m collecting useful tips and tricks for you on this website.

I’m looking forward to hearing from you and to see what you think about Yoink 3.2. If you like the app, please consider leaving a little review on the Mac App Store, it would help me out a lot!
Should you have trouble with it or have any feedback or questions, please be sure to get in touch, I’d love to hear from you! Thank you.

Eternal Storms Software Logo

– – – Do you enjoy my blog and/or my software? – – –

Stay up-to-date on all things Eternal Storms Software and join my low-frequency newsletter (one mail a month at most).
Thank you 🙂

Read more

On twitter, the question was posed if the Ink System Preferences pane could be installed without having a supported graphics tablet.

I immediately jumped to answer: YES, there is!
I remembered because I’ve had a need for this myself, way back when the OS X sandbox was introduced.

Why I Know This

Every now and then, I get an eMail from a graphics tablet user, describing how they suddenly aren’t able to drag files out of Yoink anymore. No warning. No apparent signs to why Yoink wouldn’t do its duty anymore. And all the console would say is “sandbox: deny hid-control”.
Thankfully, now, I know what it means and I can give users directions on what to do. However, after all these years, Apple still hasn’t done anything (not one thing!) about this bug in the sandbox, and it’s insanely irritating.

For me to be able to confirm that it had in fact to do with OS X’s handwriting recognition, aka Ink, i had to find a way to activate it, without actually having a graphics tablet at my disposal.

I tried doing the obvious thing (navigating to /System/Library/PreferencePanes/ and double-clicking Ink), but that only resulted in this error message:

Ink Install Error

Install The Ink System Preferences Pane

If you, too, need to test some stuff with Ink, even though you currently don’t have a graphics tablet handy, here’s how to do it.

After a lot of trial and error, this is the working solution I came up with:

  1. In Finder, navigate to /System/Library/CoreServices/Menu Extras
  2. Double-click onto Ink.menu

This item will appear in the right part of your menu bar (notice how it’s perfectly updated for the dark appearance of the menu bar… NOT) :

Ink menu bar icon

Now, click on Ink Preferences… and it will launch System Preferences for you, installing the Ink preference pane:

Ink preference pane

A restart of System Preferences removes the preference pane again, though you’ll continue to be able to install it using the menu bar item.
Should you have the wish to remove Ink from your menu bar, hold down the command key (⌘) on your keyboard and drag the item off, then release the mouse button. The poof-animation will appear, indicating that the item has been successfully removed.

Eternal Storms Software Logo

– – – Do you enjoy my blog and/or my software? – – –

Stay up-to-date on all things Eternal Storms Software and join my low-frequency newsletter (one mail a month at most).
Thank you 🙂

Read more

Yoink 3.2 comes with a handful of new features. In this post, I will … NOT tell you about those. Instead, I’d like to focus on what changed under the hood.
I think it can be interesting to reflect on how things change from release to release and what improvements were made. And how.

I’ll write about performance improvements and perceived speed-ups in the app and how I managed to improve Yoink’s handling of resources within the OS X sandbox to be able to hold more files than it was previously able to.

Performance Improvements and Speed-Ups

Let’s begin with low-hanging fruit, shall we?

I improved the responsiveness and perceived performance of Yoink in a couple of subtle, but nonetheless important places:

Make “Clear All” Faster

This is the perfect case of “put work on another thread to make the app seem faster”.

Files that don’t exist on the disk yet (like images from websites, text snippets from documents, a file from an FTP client, etc.), Yoink has to create and therefor, when they’re removed from Yoink, they need to be deleted from disk as to not waste space.

For this, I have a method named -prepareForRemoval. It checks if the file was created  by Yoink itself and deletes the file from the disk.

Now, the way “Clear All” works is fairly straight forward:

  1. Iterate over each item in Yoink
  2. Check if the file is currently pinned in Yoink. If it is, skip it; if it isn’t, continue with
  3. Call -prepareForRemoval that cleans up any files that we don’t need anymore
  4. Update the tableView
There’s a few things I’ve improved here:
For starters, for removing files out of the array that powers the tableView, I had used another array that held the items to be removed and after the loop was done, removed the files from the main array.
This I’ve replaced with -filterUsingPredicate:. It’s not only much cleaner to read, but also more performant and using less resources (getting rid of the superfluous array and the second loop for iterating over it for removal).
Secondly, I took step #3 (calling -prepareForRemoval for each item) out of the filtering method and put it on a background thread that gets executed concurrently with everything else, making the filtering much faster.
It doesn’t make any difference for just a few files, but once there are more than 20 files in Yoink and they’re all cleaned out at once, you can definitely begin to notice it.
It’s almost instant now, no matter how many items there are in Yoink.

Make Splitting Up Stacks Faster

A Stack in Yoink is an item that encapsulates multiple files, created by dropping more than one file to Yoink in one single file-drag. The Stack can be split up so individual files can be dragged out of it.

A Stack in YoinkA Stack in Yoink

Splitting up works fine, but again, if a Stack holds more than just a few files, there might be slow-downs. I can’t entirely get rid of those because of the work that needs to be done, but I can speed up the process.

It used to be a simple for-loop, iterating over the files in the Stack and creating a new item in Yoink for each one.
Now, the method uses concurrent enumeration, by calling
[array enumerateObjectsWithOptions:NSEnumerationConcurrent usingBlock:^(aBlock)].
It makes the system create as many threads as it sees fit under the current system load and configuration and loops over the array concurrently, making splitting up larger Stacks noticeably faster.

Accepting a Drop

Accepting a drag in Yoink

Because of changes equivalent to brain surgery (which I’ll discuss below), I had to speed up accepting files in Yoink, otherwise it would be perceived as slower than the previous version, and that’s unacceptable.

Again, NSEnumerationConcurrent to the rescue. It can do wonders.

On the other hand, sometimes it can be slower than an ordinary for-loop, because there’s the overhead of the thread-creation that goes on behind the scenes.
For example, the equivalent to NSEnumerationConcurrent for sorting is NSSortConcurrent. If you use it for something very simple, though, like comparing two strings, it doesn’t do much good. For more complex comparing, it might speed up your method. Another example, NSEnumerationConcurrent would not have given me any speed-ups before the brain-surgery in Yoink.

Removing Sandbox Limitations in Yoink (a.k.a Brain Surgery)

In older versions of Yoink, the app would start behaving incorrectly once a certain amount of files were added to it over the course of the app’s session lifetime. It’s a direct result of how the sandbox hands NSURLs to your app.

Files can be added to an app via the Open dialog (known inside the sandbox as Powerbox) or via drag and drop – which is what Yoink is doing.
These files come in the form of NSURLs. In the sandbox, NSURLs that hold references to files can’t just be used nilly-willy, access to them has to be started (-startAccessingSecurityScopedResource) and stopped (-stopAccessingSecurityScopedResource).
When a file is added through the powerbox or a drag, the system automatically calls -startAccessing(…) for that NSURL for you before it is passed to you in code (without telling you. Also, it causes problems: see Addendum #1).

The documentation has the following to say about -startAccessing(…):

If you fail to relinquish your access to file-system resources when you no longer need them, your app leaks kernel resources. If sufficient kernel resources are leaked, your app loses its ability to add file-system locations to its sandbox, such as via Powerbox or security-scoped bookmarks, until relaunched.

So, -startAccessing(…) and -stopAccessing(…) have to be balanced, otherwise resources are leaked and no further files can be handled by the app – which is exactly what caused earlier versions of Yoink to misbehave once a certain amount of files have been added to it, because I didn’t balance the -startAccessing(…) call the system made before handing the NSURL to me.

The obvious solution, then, is to indeed call -stopAccessing(…) once you receive the NSURL and call -startAccessing(…) once you really need to access the file. But there’s where things go downhill. Once you stop accessing an NSURL, the sandbox believes you never had access to it in the first place, and any subsequent call to -startAccessing(…) fails. Unless…

NSURL’s Security-Scoped Bookmarks (the actual Brain Surgery Part)

Unless you create a security-scoped bookmark of the NSURL first and then call -stopAccessing(…). In versions prior to 3.2, I created bookmarks only when the app quit, in order to keep access to files over relaunches and restarts.
While the app was running, though, I only handed around and worked with NSURLs (with the limitation that once ~1.500 files were added to it, the app would seize to work properly and needed a restart).

This is what I do now, to allow for many, many more files than ~1.500 to be added during the app’s run:
The first thing I do when I receive an NSURL from the drop is create a bookmark from it. Subsequently, I call -stopAccessing(…) (important: without first calling -startAccessing(…), as the system has already done that for me at that point) and the resource is freed – the app is now in a state just like right from launch – as if no file had been added yet.

But now I have an NSData object where an NSURL object used to be – pretty incompatible. That’s where the brain surgery came in. It sounds trivial, but switching from NSURL to the bookmark and making sure the resource is accessed in all the right places (and not unnecessarily) and also cleaned up was an unexpected amount of work.

But long story short, the brain surgery worked, and the patient is up and well. No spasms. No drool.

Eternal Storms Software Logo

– – – Do you enjoy my blog and/or my software? – – –

Stay up-to-date on all things Eternal Storms Software and join my low-frequency newsletter (one mail a month at most).
Thank you 🙂

Resource Usage Improvements

In the second part of this post, I’d like to explain how I was able to reduce not only Yoink v3.2’s memory footprint, but its overall resource usage.

In Yoink, I want to be able to reflect changes in filenames and be aware of file deletion – it’s a better user experience when, if a file is renamed in Finder, that file also updates its filename inside Yoink.
And there’s not much use in having a file in Yoink that’s been deleted a while ago.

Watching Files for Renames

For this, I use dispatch_sources to watch NSURLs.

GCD provides a suite of dispatch sources—interfaces for monitoring (low-level system objects such as Unix descriptors, Mach ports, Unix signals, VFS nodes, and so forth) for activity.

I want all the information I can get right from the start – probably a habit I picked up during the development of flickery, where flickr counts the number of API requests and once you hit a certain limit, you’re cut off.
So up until now, I created a dispatch_source for every single file that was added to Yoink – better safe than sorry, right?

Well, wrong! dispatch_sources are limited as well, as you need to call open() on the files you’d like to watch. The limit lies around 2.500 files (which, if the NSURL-issue I described above hadn’t already limited the amount of files Yoink could accept, would limit the amount of files Yoink could accept).

No. I needed another, saner and resource-friendlier approach.
Sane and resource-friendly? Bye-bye, polling. You’re out of the race. Good riddance.
Now, three facts are painfully obvious, in the case of Yoink. There are three promising places for improvement, as I don’t actually need to watch:

  • … files that were created by Yoink (images from websites, text snippets, any files that haven’t actually been written to disk yet…)
  • … files that are scrolled out of view in Yoink
  • … files that are encapsulated in a Stack

Files that were created by Yoink don’t need to be watched for name-changes

Text Snippet in Yoink

Files Yoink creates itself are inside Yoink’s sandbox container (at /Users/name/Library/Containers/) and managed by Yoink. No need to watch those.
Text snippets especially – their names are created based on their contents.

Files that are scrolled out of view don’t need to be watched for name-changes

Out of view files in Yoink

Imagine this: You have 9 files in Yoink, separately. You have it set up to show 3 at a time. Currently, you see files 4, 5 and 6. You definitely want to be notified when the name of any of these three files changes in Finder, as the user can currently see them in Yoink, so the changes need to be reflected right away.
But what about files 1, 2, 3 and 7, 8, 9? Do they need to be updated if the user can’t see them right now, anyway?

No!

We watch only visible files, and already we’ve reduced the files to watch for name changes from 9 to 3, saving ~67% of valuable resources – which also means more performance (no extra code execution for those 6 files) and less memory usage. (API side-note: In an NSTableView, you can get the currently visible rows by passing the rect you get from -visibleRect to -rowsInRect:).

If a user scrolls, though, the visible files change and the watched files might now be out of view, being completely useless.
Due to this, Yoink needs a mechanism to update which files need to be watched for filename changes. They are updated when:

  • files are added
  • files are dragged out or removed
  • the window’s size changes
  • Stacks are split up
  • a scroll ends
The update mechanism discards the dispatch_sources for previously visible files and sets up watching the newly visible files.

Files that are in a Stack don’t need to be watched for name-changes

Stacks in Yoink

Yoink displays Stacks like you see in the picture above. An icon, with the number of files inside the Stack. There’s actually no need to watch those files, as file name changes wouldn’t be reflected anyway.
This has “opportunity” for resource-savings written all over it.

When to actually update filenames for files that aren’t being watched

So, when are those filenames updated?
Files that are currently not visible might be visible later because the user scrolls to them or files are removed and dragged out.
Files in Stacks might be exposed by splitting them up.
There needs to be some way to update those filenames, even if they’re not actually being watched by the app right now.

Files in a Stack are actually easy – the filenames are created as soon as the user decides to split the Stack up, as Yoink gets the NSURLLocalizedName for each file.

Files currently not visible require a bit more work, but nothing too difficult.
OS X thankfully provides notifications for when a scroll occurs. Depending on the version of OS X you’re targeting, there’s either NSViewBoundsDidChangeNotification (OS X 10.8 and earlier) or the more fine-grained NSScrollViewWillStartLiveScrollNotificationNSScrollViewDidLiveScrollNotification and NSScrollViewDidEndLiveScrollNotification (OS X 10.9 and newer). For a caveat regarding “legacy” mice, see Addendum #2.

When the *WillStart* notification is sent, I start updating all filenames in Yoink in a background thread (all filenames, because I don’t know where the scroll is going to end).
Once *DidEnd* is called, I update the files to be watched with my usual routine of getting the -visibleRect. Then I update the filenames for the now visible files, just in case the background-thread is still running and hasn’t come to those files yet.

Watching For File Deletion

A warning message when a file residing in Yoink is moved to the Trash in FinderYoink 3.2 displays a warning once a session when a fie is moved to the Trash.

Watching for files being moved to the trash or deleted altogether is another beast entirely.
For this alone, I’d have to watch every single file – being in a stack, not currently visible, etc. -, effectively subverting every single improvement I had hoped for above.
There had to be a better way.

Luckily for me, there is.

I had the idea that, if a file or folder could be watched, the Trash itself should be watchable too, meaning that instead of having to watch every single file if it was moved to the trash or deleted, I’d only have to watch one Trash folder for each volume attached to the Mac (because external volumes have their own Trashes).

Since dispatch_source is my go-to-API for watching files (and I have experience with it), I set up a test-app that watched all Trash(es) folders on the Mac. Surprisingly, it worked only for the internal volume, external volume’s Trashes folders couldn’t be watched. Busted.

FSEvents to the Rescue

Just when it looked like all hope was lost, I remembered the FSEvents API:

[The FSEvents] API provides a mechanism to notify clients about directories they ought to re-scan in order to keep their internal data structures up-to-date with respect to the true state of the file system. (For example, when files or directories are created, modified, or removed.)

It was worth giving it a shot, and – again, surprisingly – watching external volume’s trashes for changes worked this time around. Success.
Now I can tell whether a file in Yoink was moved to the Trash or deleted, without having to set up a dispatch_source for every file and without having to do any polling.

In Closing

Having had code in Yoink that could render the app useless after a couple of thousands files had been added makes me uncomfortable and is pretty embarrassing to admit, but I’m glad I got rid of it.
I’m also very happy with the improvements made with the upcoming update.
In many places, Yoink feels much more responsive because of them.

Addenda

Addendum #1

An NSURL you receive from the powerbox or a drag’n’drop operation already has started access to the resource it points to. This causes the problem that file drags with more than ~1.500 files behave incorrectly (your mileage may vary). The first ~1.500 files are added just fine, but suddenly you start seeing something like this in your logs:

Yoink[74545]: Consume sandbox extension for itemIdentifier (9035) with path: /some/file/path from pasteboard failed!

And worse, the NSURLs you receive beyond that point are useless, you can’t access the files they point to.
My understanding is that this would be a non-issue if the system didn’t automatically call -startAccessing(…) before it hands the NSURLs to you and lets you decide when to startAccessing the NSURLs.
As far as I can tell, this is an issue that can not be worked around at this time, and I’ve tried a couple of things. I hope Apple is working on it. One should believe since 10.7, they’ve had enough time.

Addendum #2

A legacy mouse, as in, a mouse that has a traditional scroll wheel, will only call NSScrollViewDidLiveScrollNotification, not *WillStart* or *DidEnd*.
I handle that in Yoink by calling the update method delayed, and canceling the delayed call should another *DidLiveScroll* notification occur in the meantime, this way, I “simulate” *WillStart* and *DidEnd*:

[NSRunLoop cancelPreviousPerformRequestsWithTarget:self selector:@selector(scrollingDidEnd:) object:nil];
[self performSelector:@selector(scrollingDidEnd:) withObject:nil afterDelay:0.15];

Eternal Storms Software Logo

– – – Do you enjoy my blog and/or my software? – – –

Stay up-to-date on all things Eternal Storms Software and join my low-frequency newsletter (one mail a month at most).
Thank you 🙂

Read more