Files that aren’t: how Safari puts weblocs on pause

When an app writes a file, it’s expected to close and release that file for others to use. If it doesn’t – particularly when it’s an app which you’re likely to leave open a lot of the time – it can cause mayhem. This article describes a bug in which Safari 12.1.1, released just a couple of days ago, and possibly earlier versions, fails to close and release files, with serious consequences.

Reproducing the bug is straightforward when you follow this sequence carefully:
safaribug01

  1. In Safari, press Option-Command-B to switch to the Bookmarks page.
  2. If you already have a folder in your Bookmarks, simply drag that folder across and drop it on your Desktop. If you don’t have a folder, click on the New Folder button at the top right of the page, and drag that folder into your Bookmarks. Then Option-drag some of your existing bookmarks into it, to copy them there. You don’t need many in that folder, just a few should be fine.
  3. Page Back in Safari to return it to the previous page and leave that browser open.
  4. Open the folder of bookmarks on your desktop, and try dragging it anywhere else, such as into your Documents folder, or moving it to the Trash.

What then happens is that the Finder, or any other app, prepares to perform your action, but cannot complete it. In the case of moving that folder elsewhere, you’ll see the standard progress window just sat there, preparing for ever. You can click on the Cancel button, but you just cannot get the action to complete.

safaribug02

If you want to feel more confused, open that folder of webloc files in the Finder, and switch to Gallery view. After a short delay, each of your weblocs will preview correctly.

safaribug03

But open my free utility Precize, and in that try to open one of those weblocs, and nothing happens at all. You can do the same with apps capable of opening any filetype, such as BBEdit, which behave identically.

If you try that in Precize and leave that app open, then quit Safari, a very odd thing happens. Once the browser has quit, the webloc you tried to open in Precize suddenly opens, and any Finder actions should immediately complete.

safaribug04

Safari 12.1.1 can make perfectly good webloc files from its bookmarks, for example by dragging them from Bookmarks in the sidebar. But when they’re dragged in a folder from the Bookmarks page, it refuses to close and release them so that other apps can move or, in many cases, even open them. The only solution is to quit the Safari app, which automatically releases those webloc files so that they can work normally.

This bug appears to be the result of Safari 12.1.1 failing to properly close and release the weblocs it has written from its Bookmarks page. If so, that’s a bit of a schoolboy howler, and not the quality of code you’d expect to see in a release version of a major product. Go hand your head in shame, Apple: you’re still not doing software engineering right.

Thanks to Dimitris for reporting this bug in macOS 10.14.4 and 10.14.5.