Actually, can’t you disable screen updating while you’re swapping images?
> On May 12, 2020, at 3:35 PM, Alex Zavatone via Cocoa-dev > <cocoa-dev@lists.apple.com> wrote: > > Care to post a video on a Google drive so that we can see it? > > One of my tricks (not just mine) is to have a 3 slots of for images, not just > 2. When a new image loads, take the foreground one that is blended in to > 100%, put an identical one ahead of it. Make the changes to the new and old > images behind it, then hide that foreground image. > > You’re actually using a copy of the foreground image as a mask and you > perform the swap behind it, then update the screen, then remove the top level > one and refresh again. > > This is if I’m understanding what you’re going properly. > > I’d expect that Apple’s video system to actually handle this if it still > triple buffers, but it’s been 25 years since I read the docs on the Mac’s > video subsystem. > > > In the mean time, add logging code that you can put breatpoints on and take a > screen grab when you log. That should help. > > Cheers, > Alex Zavatone > >> On May 12, 2020, at 3:27 PM, Gabriel Zachmann via Cocoa-dev >> <cocoa-dev@lists.apple.com> wrote: >> >> Thanks a million to everyone who has shared insights, hints, and advice on >> this. >> >> I have restructured my code, so now I do the heavy lifting of loading images >> in a serial dispatch queue. >> However, there is still sometimes some stuttering visible in the animation >> of the images. >> Does anyone have an idea what might be causing it? >> >> Here is the current structure of my code, given in sort of a pseudo-code: >> >> -animateOneframe: >> // essentially, this gets called when the next image is to be displayed >> current_image_ = prefetched_image_; // these are CGImageRef's >> dispatch_async( prefetch_queue_, ^{ >> [self loadNextImage]; >> } ); >> create a new CALayer, >> assign the current_image_ as content, >> create an animation for the layer, >> add the layer to the layer hierarchy >> >> In -loadNextImage, I am doing all the heavy lifting of loading images >> (and the not-so-heavy), such as: >> prefetched_image_ = nil; >> CGImageSourceGetStatus >> CGImageSourceCopyPropertiesAtIndex >> CGImageSourceCreateThumbnailAtIndex >> imageByApplyingOrientation >> createCGImage >> prefetched_image_ = new image >> >> (I know there is some potential race condition here, but that is not of >> concern to me right now.) >> >> Overall, I get the impression that it is "better" (less stuttering), >> but sometimes there is still a stuttering in the animation when the app >> makes a transition from one image to the next one. >> >> How could that be? >> >> Using Instruments, I can see this in the "heaviest stack trace" when CPU >> usage is high in the main thread: >> >> 41 CoreFoundation 3897.0 __CFRunLoopDoObservers >> 40 CoreFoundation 3897.0 >> __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ >> 39 QuartzCore 3896.0 >> CA::Transaction::observer_callback(__CFRunLoopObserver*, unsigned long, >> void*) >> 38 QuartzCore 3896.0 CA::Transaction::commit() >> 37 QuartzCore 3895.0 CA::Context::commit_transaction(CA::Transaction*, >> double) >> 36 QuartzCore 3895.0 CA::Layer::prepare_commit(CA::Transaction*) >> 35 QuartzCore 3895.0 CA::Render::prepare_image(CGImage*, CGColorSpace*, >> unsigned int, double) >> 34 QuartzCore 3895.0 CA::Render::copy_image(CGImage*, CGColorSpace*, >> unsigned int, double, double) >> 33 QuartzCore 3895.0 CA::Render::(anonymous >> namespace)::create_image_by_rendering(CGImage*, CGColorSpace*, unsigned int, >> double, CA::Render::ImageCopyType) >> >> Are these functions the culprits? How can I make them get executed in the >> background? >> >> >> All insights will be highly appreciated. >> >> Best regards, Gabriel >> >> _______________________________________________ >> >> 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: >> https://lists.apple.com/mailman/options/cocoa-dev/zav%40mac.com >> >> This email sent to z...@mac.com > > _______________________________________________ > > 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: > https://lists.apple.com/mailman/options/cocoa-dev/zav%40mac.com > > This email sent to z...@mac.com _______________________________________________ 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com