告诉 IKImageBrowserView 不要安排预加载

发布于 2024-08-07 19:08:28 字数 612 浏览 7 评论 0原文

为了重写开源 iMedia 框架项目(目前有数十名开发人员正在使用),我们正在切换到 IKImageBrowserView,并且在缓存方面遇到了麻烦。

看来 IKImageBrowserView 喜欢预加载/预取图像缓存,作为低优先级后台任务,以及尽可能多的尚未可见的项目。这可能很有用,只是我们不想加载 CPU(以及用于远程检索图像的网络)(如果可以的话)。

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

有什么方法可以禁用这个预加载器的调度吗? (即使有一个我们现在可以小心使用的未记录的 API,我也一定会提出一个请求,将其变成公共 API,因为能够关闭这种危险的功能确实至关重要。)

这确实会影响很多应用程序。您可以建议的任何解决方法将非常感激。

顺便说一句一些相关的讨论: http://lists.apple.com/archives/cocoa- dev/2007/Nov/msg02011.html

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.

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.

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.

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 Some related discussion:
http://lists.apple.com/archives/cocoa-dev/2007/Nov/msg02011.html

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

桜花祭 2024-08-14 19:08:28

我自己已经开始使用 IKImageBrowserView,之前没有注意到这一点,但实际上我尝试过,并且在我自己的应用程序中看到了相同的行为。

看起来 IKImageBrowserView 上有一个名为 _shouldProcessLongTasks 的私有方法。我尝试覆盖它以仅返回 NO,这似乎可以防止视图中尚不可见的图像的预加载行为(至少在 Snow Leopard 下,必须在 Leopard 下进行测试以查看行为是否相同) 。看起来风险相当低的私有 API 使用,因为如果方法发生变化,它就不会再被调用。当您向 Apple 提交有关此问题的错误时,请发布雷达编号,以便其他受影响的人可以对其进行欺骗,并尝试为此获取公共 API 和/或行为更改。

根据记录,当前的行为似乎是,只要应用程序位于前台并且包含视图的窗口是关键,它就会在后台预取内容。如果您切换到另一个应用程序或窗口,它将停止预加载。

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.

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文