> On 22 Sep 2016, at 8:59 AM, Gabriel Zachmann <z...@tu-clausthal.de> wrote:
> I am a bit at a loss about the MLMediaLibrary API.
> Maybe, I haven't quite understood it yet, maybe something else is wrong.
> I am writing a screen saver that accesses Photos' albums and the images 
> referenced by them.
> (Code excerpts follow at the end of this email.)
> I create an array of the top level albums at startup time of the screensaver 
> , using the KVO.
> At runtime, I occasionally extract the images referenced by one of those 
> albums.
> Most of the time it works fine, except sometimes, my KVO never gets invoked, 
> at which point my screensaver hangs,
> because I had to stop the animation during that phase.
> I have not found a pattern as to when this happens.
> (it is not a deterministic album, nor a deterministic n-th time.)
> Any suggestions, hints, insights, and pointers will be highly appreciated.

I’ve run into some unreliability in MLMediaLibrary. It appears to be a bug 
because it sometimes can be seen in places that use MLMediaLibrary within 
general standard components, such as NSOpenPanel (this adds a media browsing 
section if it is set up to allow image types, for example). Sometimes it only 
shows the top level of the library, and all of the subgroups are simply 
missing, and never show up no matter how long you wait. Opening the panel a 
second time will finally deliver the subgroups.

My guess is that as it’s an asynchronous API, on the first pass the system has 
to build a lot of internal cached state, and it may fail for any reason. On the 
second pass, it has already primed much of that cache and the failure doesn’t 
occur. While this happens quite often, it’s not every time, so I haven’t 
spotted an absolute pattern.

But I think your code needs to be designed in such a way that if the KVO it is 
expecting (for the contents of a given group, say) is never delivered, it 
doesn’t fail. I’m not sure that is really possible for a photos screensaver (in 
that case you have no photos to display), but there’s no reason it needs to 

Hopefully 10.12 will fix the issue, but I haven’t had a chance to look into 
that yet.



Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to arch...@mail-archive.com

Reply via email to