Here’s What Was Really Going on with the iOS 17.5 Bug That Resurfaced Deleted Photos

iPhone Photos app icon Credit: Tada Images / Shutterstock
Text Size
- +

Toggle Dark Mode

A change in iOS 17.5 stirred up quite a controversy last week as numerous folks saw deleted photos from ages past suddenly reappearing in their Photos app after installing the update. Apple quickly addressed the issue in iOS 17.5.1, but it didn’t say much about the problem except that it was a “rare issue” related to “database corruption.”

That explanation didn’t do much to quell the concerns of many who feared that sensitive images they had thought long deleted were still lurking around waiting to reappear at an inopportune time.

This also led to cynical suspicions that Apple was hoarding everyone’s photos in iCloud for possibly nefarious purposes. That’s an absurd notion on the face of it, but it also didn’t make sense, as many people who encountered the problem weren’t using iCloud Photos at all. Some weren’t even signed into iCloud.

It also didn’t help alleviate people’s panic when a random poster on Reddit claimed their personal photos had reappeared on a device they’d wiped and sold. We were skeptical of that one from the beginning since that’s not how things work. A charitable view is that the poster was mistaken, but they could have been deliberately trolling. Either way, the post didn’t last more than a day or two before it was removed, and the original poster’s account no longer exists on Reddit. That’s probably all we need to say about the veracity of that claim.

What Happened to Bring These Photos Back?

When iOS 17.5.1 was released with a fix and the note about “database corruption,” my experience suggested that the issue was a result of “orphaned” photos — image files that were still stored in the Photos library but not referenced in the Photos database.

This was merely educated speculation on my part, but as someone who has worked with the innards of Apple’s media management software for about 20 years, it seemed like the most logical explanation.

Apple has more or less confirmed this to 9to5Mac. While it hasn’t gone into extensive detail, it told Chance Miller that iCloud Photos had nothing to do with the problem and was simply a result of “the corrupt database entry that existed on the device’s file system itself.” Apple also told Miller in no uncertain terms that the claim of photos reappearing on a device that was wiped and sold “was false.”

According to Apple, the photos that did not fully delete from a user’s device were not synced to iCloud Photos. Those files were only on the device itself. However, the files could have persisted from one device to another when restoring from a backup, performing a device-to-device transfer, or when restoring from an iCloud Backup but not using iCloud Photos.Chance Miller, 9to5Mac

There are generally two ways of storing large binary files like photos, videos, and audio in a database. One method uses what’s known as BLOBs, which is short for “Binary Large Objects,” placing the media files directly into a database field. The other way is to store the raw media as files in their original formats and use a database to store and index their metadata for faster lookups.

Apple has generally opted for the latter approach. iTunes, iPhoto, Aperture, and Photos all store images in their native formats, typically using a SQLite database to index them and keep track of other related information such as what albums or playlists they’re in. iTunes (now Music) leaves MP3 and other audio files in standard user-accessible folders, while Apple’s Photos app hides them in a custom folder structure within a library “package” (which is effectively just a folder that’s designed to look like a single file).

If you’re curious, you can see this on your Mac by locating the Photos Library (typically found in your Pictures folder), right-clicking on it, and choosing Show Package Contents. This will open a folder view in Finder, showing you everything that’s inside.

If you try this, be very careful not to delete, move, or rename anything. However, you can safely browse through it without causing any problems. Inside, you’ll see a “database” folder that stores all the information about your photos. Dig deep enough into the “originals” or “resources/derivates” folders, and you’ll see all your media files scattered about. The Photos Library is laid out similarly on your iPhone and iPad.

The catch is that Photos doesn’t scan these image files directly during normal operation. Instead, it relies on the database to provide quick access. When you import a photo, it gets added to the database, and when you delete a photo, the database entry gets removed along with the file.

At least, that’s how it’s supposed to work. When faced with bugs, database corruption, or crashes, it’s entirely possible for a database entry to get removed while the file remains. The image will disappear from view, but it’s not truly gone; the media file is still sitting in the library, now invisible to anyone who doesn’t delve into it with a file browser — something that’s basically impossible to do on an iPhone or iPad without resorting to jailbreaking.

Along the same lines, it’s possible for a new photo or video file to be saved into the library without the corresponding database entry being properly added. This is what happened to another Redditor, who found that iOS 17.5 was a welcome update as it brought back photos that they’d thought lost forever after their iPhone froze up while taking photos.

Since the underlying files are still in the Photos Library folder, and that entire folder gets backed up along with the rest of your iPhone, they’ll come along for the ride whenever you transfer your data to a new iPhone, which is something that nearly everyone does when upgrading. That’s why many folks saw photos from a decade ago resurfacing, even though they’ve long since replaced the iPhones they were taken on.

The bottom line is that these deleted or missing photos were never fully gone — they were always hiding in the Photos Library (the local on-device one, not iCloud Photos) and iOS 17.5 merely brought them back into the database, likely by doing a database repair, scanning all of the JPG and other media files in the Photos Library, and adding any missing ones back to the database. The same thing will happen if you repair your Photos Library on a Mac, but the iPhone/iPad Photos app has no such user-accessible tool. Presumably, Apple decided it was a good idea to run a similar library check and repair for everyone as part of the iOS 17.5 update, which picked up any orphaned photos lying around and put them back into the Photos Library.

Social Sharing