Waiting for UIWebView with Dispatch Semaphores
I’m trying to create a synchronous method on iOS (4.2.1) to create a thumbnail image for a PowerPoint file. To accomplish this, I want to load the file into a web view, then wait for it to load, then render its context into a new graphics context and save it to an image. Here’s what I have so far: http://pastie.org/1395434 I’ve tried adding the web view as a subview of the UIWindow to force it to render, but that didn’t seem to matter. The problem is line 26: waiting for the semaphore to be signaled blocks the thread, and the web view won’t load. None of the delegate methods will ever be called while I’m blocking. Is there a way to synchronously wait for the web view? All combinations of splitting things off on separate threads fall apart when I try to wait for the image to be created. Thanks in advance for any suggestions. Jeff Kelley ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Waiting for UIWebView with Dispatch Semaphores
On Dec 21, 2010, at 8:52 AM, Jeff Kelley wrote: Is there a way to synchronously wait for the web view? All combinations of splitting things off on separate threads fall apart when I try to wait for the image to be created. Why do this synchronously at all? The web view already gives you a notification, use that to generate your thumbnail and signal the caller. Also consider that if the rendering takes a significant time, blocking the main thread *will* cause your application to be killed by the watchdog timer. Basically trying to do this synchronously is not only a waste of time, but a dead end that will fail for anything but the simplest of scenes. -- David Duncan ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Waiting for UIWebView with Dispatch Semaphores
On Tue, Dec 21, 2010 at 11:59 AM, David Duncan david.dun...@apple.com wrote: Why do this synchronously at all? The web view already gives you a notification, use that to generate your thumbnail and signal the caller. What I’m trying to do is create a thumbnail for a PowerPoint that, when clicked, opens a web view with the PowerPoint inside. I’d like it to be synchronous so that I can create thumbnails on demand if they aren’t already created. I’ll probably move forward with something that creates a full-size image asynchronously on downloading the PowerPoint, then dynamically resize that image to make my thumbnail, but this feels like something that *should* be possible. Also consider that if the rendering takes a significant time, blocking the main thread *will* cause your application to be killed by the watchdog timer. Basically trying to do this synchronously is not only a waste of time, but a dead end that will fail for anything but the simplest of scenes. The alternative, then, would be to find a way to render a PPT on a background thread, which UIWebView doesn’t seem suited for. Thanks for your comments. Jeff Kelley ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com