告诉IKImageBrowserView不要调度预加载 [英] Telling IKImageBrowserView not to schedule preloading

查看:139
本文介绍了告诉IKImageBrowserView不要调度预加载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于我们重写的开源iMedia框架项目(目前由几十个开发人员使用),我们正在切换到IKImageBrowserView,并有一个麻烦的时间与缓存。

For our rewrite of the open-source iMedia framework project (in use currently by dozens of developers), we are switching to IKImageBrowserView, and having a troubling time with caching.

看起来IKImageBrowserView喜欢预先加载/预取图像的缓存作为低优先级的后台任务,尽可能多的不可见的项目。这可能是有用的,除非我们不想加载CPU(和网络远程检索的图像),如果我们可以帮助它。

It appears that IKImageBrowserView likes to preload/prefetch a cache of images, as a low-priority background task, as many not-yet-visible items that it can. This might be useful, except that we don't want to load the CPU (and network for remotely-retrieved images) if we can help it.

特别是因为我们有我们自己的FIFO缓存机制(所以我们可以与其他视图共享我们的缩略图数据到相同的数据),所有这些都是填满缓存的容量,然后导致较旧的项目被转储。

Especially since we have our own FIFO caching mechanism (so we can share our thumbnail data with other views into the same data), all this is doing is filling up the cache up to capacity and then causing the older items to be dumped.

有没有办法禁用此预加载器的调度? (即使现在有一个没有文档的API,我们现在可以使用它,我会确保打开一个请求,使其成为一个公共API,因为它是非常关键,能够关闭这个危险的能力)。

Is there some way to disable the scheduling of this preloader? (Even if there is an undocumented API that we can gingerly use for now, I'll be sure to open up a request to make it into a public API, since it is really critical to be able to turn this dangerous capability off.)

这将真正影响很多应用程序。您可以建议的任何解决方案将非常感激。

This will really affect a lot of applications. Any work-arounds you can suggest would be very much appreciated.

BTW一些​​相关的讨论:
http://lists.apple.com/archives/cocoa-dev/2007/Nov/msg02011.html

BTW Some related discussion: http://lists.apple.com/archives/cocoa-dev/2007/Nov/msg02011.html

推荐答案

我一直开始使用IKImageBrowserView,我以前没有注意到,并且我看到与我自己的应用程序相同的行为。

I've been starting to use IKImageBrowserView myself, and I hadn't noticed this before, but indeed I tried it out and am seeing the same behavior with my own app.

看起来像IKImageBrowserView有一个私有方法称为_shouldProcessLongTasks。我试图覆盖它只是返回NO,这似乎防止了在视图中尚未可见的图像的预加载行为(至少在雪豹下,必须在Leopard下测试,看看行为是否相同) 。看起来像一个相当低风险的私人API使用,因为如果方法更改,它将不再被调用。当你在Apple上提交bug时,请发布雷达号码,以便其他受影响的人可以在其上提交一个副本,并尝试获取一个公共API和/或行为更改。

It looks like there's a private method on IKImageBrowserView called _shouldProcessLongTasks. I tried overriding it to just return NO, and that appears to prevent the preloading behavior for images that aren't yet visible in the view (at least under Snow Leopard, would have to test under Leopard to see if the behavior is the same). Seems like a fairly low-risk private API usage, since if the method changes, it simply won't be called anymore. When you file a bug with Apple on this, do post the radar number so others affected can file a dupe on it and try to get a public API and/or behavior change for this.

对于记录,看起来当前的行为是,它将预取在后台的东西,只要应用程序在前台,并且包含视图的窗口是关键。如果您切换到其他应用程式或视窗,就会停止预先载入。

For the record, it looks like the current behavior is that it will prefetch stuff in the background as long as the application is in the foreground and the window containing the view is key. If you switch to another app or window, then it stops preloading.

这篇关于告诉IKImageBrowserView不要调度预加载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆