Recently—I'm not sure exactly when—iPhoto 9.5.1 started behaving very strangely on my Mac. Browsing through events, albums and photos seems to work fine. However, when I click on the Edit icon to manipulate a photo, I either see a completely black working area or what appears to be corrupt image data.
Interestingly, I can actually edit the photo, even though I can't see what I'm doing. For example, if I rotate the photo and then back out to the event view, the thumbnail shows up rotated. Also, this appears to only affect images of certain sizes: if I start with a very small photo (e.g., 600x600 pixels), editing works fine.
Here's an example of what it looks like:
I've tried a variety of suggestions I've found online (particularly in Apple's support forums), including:
- Repairing the iPhoto library.
- Rebuilding the iPhoto library.
- Removing the iPhoto preferences files.
- Removing the iPhoto cache files from /Users/user/Library/Containers/com.apple.iPhoto/Data/Library/Caches.
- Creating an entirely new test library.
- Rebooting my Mac.
- Deleting iPhoto and reinstalling via the app store.
Unfortunately, none of these approaches fixed the problem.
Interestingly, other users on my Mac can use iPhoto without problems. In fact, if I log in as a different user and load up the exact same test library I created as described above, it works fine.
With that in mind, it appears that there's something going on with my account configuration that is causing this problem, rather than an issue with the library itself, but I'm at a loss to explain what it is.
I'm still having this issue, but I tried running iPhoto from the command line and noticed that this message is logged every time the app tries to display a photo in editing mode:
clBuildProgram() failed (-11) for kernel _CIClampToAlpha.
This message doesn't appear when I run iPhoto as a different user, even using the same library, so it seems to be related to the problem I'm having, but I'm still unsure as to just how they're tied together.
Based on some additional reading, I tried running iPhoto like this:
This generated some additional log output when I tried to edit a photo:
[CL_DEVICE_NOT_AVAILABLE] : OpenCL Error : Error: build program driver returned (-2) Break on OpenCLErrorBreak to debug. OpenCL Warning : clBuildProgram failed: could not build program for 0xffffffff (Intel(R) Core(TM) i7-2600 CPU @ 3.40GHz) (err:-2) Break on OpenCLWarningBreak to debug. [CL_BUILD_ERROR] : OpenCL Build Error : Compiler build log: fatal error: cannot open file '/System/Library/Frameworks/OpenCL.framework/Versions/A/lib/clang/3.2/include/cl_kernel.h': Too many open files in system
This seemed interesting, particularly because this error doesn't appear when I (successfully) run iPhoto as a different user. However, the number of open files "in the system" isn't appreciably different in these cases, particularly since I'm using fast user switching to switch between users, so nothing much is changing between invocations. Here are the number of open files in iPhoto and system-wide on my account:
<shadow>:~ $ lsof -p 11989 | wc -l # open files in the iPhoto process on my account 221 <shadow>:~ $ sudo lsof | wc -l # open files, system-wide while iPhoto is open 12245
And here are the number of open files in iPhoto and system-wide while another user is running iPhoto:
<shadow>:~ $ lsof -p 12163 | wc -l # open files in the iPhoto process in another account 226 <shadow>:~ $ sudo lsof | wc -l # open files, system-wide while iPhoto is open 12466
As you can see, the number of open files isn't significantly different when iPhoto is run as a different user, so again, something peculiar seems to be up with my account. I remain at a loss as to what that could be, however.
Note that I've tried increasing the system-wide limit on the number of open files as follows:
<shadow>:~ $ sudo sysctl -w kern.maxfiles=20480 kern.maxfiles: 12288 -> 20480
Unfortunately, this had no effect.