cadisplaylink

CADisplayLink running lower frame rate on iOS5.1

 ̄綄美尐妖づ 提交于 2020-01-01 03:20:48
问题 I'm using CADisplayLink in my iPhone app. Here is the relevant code: SMPTELink = [CADisplayLink displayLinkWithTarget:self selector:@selector(onTick)]; SMPTELink.frameInterval = 2;//30fps 60/n = fps [SMPTELink addToRunLoop:[NSRunLoop mainRunLoop] forMode:NSDefaultRunLoopMode]; onTick is thus called every frame of 30FPS (1/30th of a second). This works GREAT on iOS6 + - does exactly what I need. However, when I ran my app on an iPhone 4s running iOS5.1, the onTick method ran slightly slower

How to set CADisplayLink in Swift with weak reference between target and CADisplayLink instance

元气小坏坏 提交于 2019-12-31 02:43:08
问题 In Objective-C, we can init CADisplayLink with Proxy Pattern to break strong reference: WeakProxy *weakProxy = [WeakProxy weakProxyForObject:self]; self.displayLink = [CADisplayLink displayLinkWithTarget:weakProxy selector:@selector(displayDidRefresh:)]; Then, just invalidate the displayLink in dealloc : - (void)dealloc { [_displayLink invalidate]; } However, NSProxy seems can't be inherited in Swift: https://bugs.swift.org/browse/SR-1715 I tried to write like this: weak var weakSelf = self

How to pause a CADisplayLink?

我的未来我决定 提交于 2019-12-23 02:40:32
问题 I have a problem in my app. What I want to happened is when I click button2, it disappears and stops moving. What's happening now is that when I click button2, it disappears but doesn't stop moving (even while its hidden).Any help? Code: @IBOutlet var label: UILabel! @IBOutlet var label2: UILabel! @IBOutlet var label3: UILabel! @IBOutlet var button2: UIButton! @IBAction func button3(sender: UIButton) { label.hidden = false button2.hidden = true } @IBOutlet var button4: UIButton! @IBAction

CADisplayLink at iOS 6.0 not retaining target

空扰寡人 提交于 2019-12-22 10:29:06
问题 I have a such code: NSInvocation* invocation = [NSInvocation invocationWithMethodSignature:[self methodSignatureForSelector:@selector(updateFrame)]]; [invocation setTarget:self]; [invocation setSelector:@selector(updateFrame)]; displayLink_ = [[CADisplayLink displayLinkWithTarget:invocation selector:@selector(invoke)] retain]; [displayLink_ setFrameInterval:1]; [displayLink_ addToRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode]; At iOS 6.0 (in 5.1 this code works ok) when this

Memory usage keeps rising on older devices using Metal

▼魔方 西西 提交于 2019-12-21 15:18:13
问题 I use Metal and CADisplayLink to live filter a CIImage and render it into a MTKView . // Starting display link displayLink = CADisplayLink(target: self, selector: #selector(applyAnimatedFilter)) displayLink.preferredFramesPerSecond = 30 displayLink.add(to: .current, forMode: .default) @objc func applyAnimatedFilter() { ... metalView.image = filter.applyFilter(image: ciImage) } According to the memory monitor in Xcode, memory usage is stable on iPhone X and never goes above 100mb, on devices

How to correctly stop and resume a CADisplayLink?

我的未来我决定 提交于 2019-12-21 07:15:18
问题 I figured out a big problem with CADisplayLink. I have the most basic EAGLLayer with OpenGL ES 1.1 drawing a rotating triangle for testing. This needs a run loop method to be called at screen refresh rate, so I start the runloop like this: - (void)startRunloop { if (!animating) { CADisplayLink *dl = [[UIScreen mainScreen] displayLinkWithTarget:self selector:@selector(drawFrame)]; [dl setFrameInterval:1.0]; [dl addToRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode]; self

Getting stuck at 40 fps even with using CADisplayLink?

依然范特西╮ 提交于 2019-12-20 17:17:13
问题 At first I used NSTimer and ran into the problem of the frame rate being stuck at 40 frames per second. I've read about using CADisplayLink to fix the problem. It seemed to work for a while, but recently, the app starts at 60, then after a little while (about 5 - 20 seconds in) the app starts to run at 40 - 41 fps and gets stuck there. And I'm culling so that there's less draws when objects are out of view, but yet it stays stuck there. A unusual way that does seem to remedy the problem for a

UIScrollView broken and halts scrolling with OpenGL rendering (related CADisplayLink, NSRunLoop)

早过忘川 提交于 2019-12-19 03:39:17
问题 Solution note, Not a question. UIScrollView suspends OpenGL rendering by preventing firing CADisplayLink tick when CADisplayLink registered with NSDefaultRunLoopMode . But, if you use NSRunLoopCommonModes to solve this, UIScrollView will halt scrolling at burst scrolling. And after once halted, it does not scroll again. (broken) And registering CADisplayLink in other thread/runloop (as described in answer of this question: CADisplayLink stops updating when UIScrollView scrolled) reduces

Why does dispatch_semaphore_wait() return YES all the time even when I'm not scrolling?

眉间皱痕 提交于 2019-12-11 07:55:57
问题 Brad Larson delivered a solution for the CADisplayLink freeze issue when scroll views are scrolling. My OpenGL ES draw method is called by a CADisplayLink , and I tried Brad's technique but can't make it work. The core problem is that my OpenGL ES view is hosted by a UIScrollView , and when the U IScrollView scrolls, the CADisplayLink stops firing. The technique Brad described is supposed to let the CADisplayLink continue to fire even during scrolling (by adding it to NSRunLoopCommonModes

Circle with fluid/strechy stroke

你。 提交于 2019-12-08 14:10:57
问题 Me and my team are working on an app for a client. We are trying to understand how to achieve this kind of animations ( refer only to the circle stroke ) : We tried using a CADisplayLink to set up and change the circle, but it generated non-fluid results. We couldn't find a way to create a circle from "components" of UIBezierPath and change each of the anchors. Any suggestions on how to achieve this kind of effect, or how to construct a circle from seperated points, would be highly appricated