-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Remove CADisplayLink #2985
Comments
So, I admit I haven't measured this, but the CPU usage should be extremely minimal. Remember that when the CADisplayLink wakes up all it has to do is check a boolean. It's not checking for whether we should render at that moment. And the CADisplayLink run loop mechanism is always running anyway; we're merely adding, at most, about one method call and maybe two or three instructions. It would be difficult to even measure the impact. |
Yeah, that was my hunch. If @kkaefer can confirm that he wasn't seeing anything more egregious, I think we can just close here then. |
It's minimal, but it still means the CPU needs to wake up. Previously, the CPU usage was reported as "zero" when the map was idling, now it's "low". |
Can you put that into context in terms of how big of a deal that is? Like, does it drain the battery or something? |
@adam-mapbox on Intel architectures that I'm more familiar with, it definitely would have an impact because that would prevent the CPU from going to a "deep" C-State. But anyway, it is just a quirk if not measured. |
The way I've used a CADisplayLink in the past is to start it on some kind of user interaction, and then let it remove itself when all its work is complete. Maybe that's an option here? |
On my 64 GB iPhone 6 running iOS 9.1, iosapp flatlines at 1% CPU usage when idle (and ticks up to 2% a couple times a minute). |
@tomtaylor There are so many different entry points for "interaction" here — gestures, but also programmatic/animated viewport changes, implicit changes for things like user dot tracking, etc. If we can confirm that we had 0% battery usage when idle previously, and that we don't now, we should fix that. |
Either way, Xcode reports zero energy impact at idle. |
Scratch that, I’m not profiling battery usage correctly. |
Building on @tomtaylor's thoughts, a naive approach that might work here is to observe app foreground/background state and suspend the Either way, I think we can move this off of the 3.0.0 milestone since this is only for app foreground mode and continue to experiment given the upside of much better rendering performance. |
One thing we could consider doing is to decrease the frequency of the tick It is theoretically possible to create a system that only ticks the On Tue, Nov 17, 2015 at 1:59 PM, Minh Nguyễn notifications@github.com
|
I made a small but impactful change to this |
BTW, I tried implementing my suggestion above, and it didn't seem to break anything, but it also didn't have any noticeable impact on the reported CPU usage or energy impact, so I abandoned it. |
I did this in #3448 by calling I’m tempted to have the CADisplayLink run only between the |
#3448 is on the 3.1.0 milestone; the remaining work will have to wait for the next release. |
We should take CADisplayLink out of the picture entirely: MGLMapView should keep track of the last render time (as a lightweight NSTimeInterval); every time mbgl calls |
To summarize this issue to date:
Next steps:
|
This is confirmed easily enough using the |
Having ok luck with nice, smooth renders, but:
|
The second point above seems to be related to viewport animations. That is, if the map is moved synchronously with the finger, annotation views stick just fine. If it is pan-tossed, camera-animated, or anything that doesn't tie to direct manipulation, the frame render callback doesn't fire, which doesn't call Hunch is that |
Render callback & |
I’ve been assuming that having mbgl drive updates was best, because mbgl has the most context about when a redraw is needed (camera transitions, property transitions, etc.). But mbgl doesn’t know anything about Core Animation. 🤔 |
The behavior here is reminiscent of hangs in animations due to scroll view tracking and display link run modes, FWIW. Will keep debugging this. |
Ok, pushed my WIP to As far as I can tell, the actual transplantation of removing The problems that crop up are related to the user and normal annotation views. Easy way to replicate:
|
Part of me also wonders if the fact that |
WELP All of the bugs described in #2985 (comment) happen in an unaltered So, I believe we can implement here and get rid of Can anyone else confirm that these bugs exist or is it just me? Edit: Scratch this; PEBKAC. 🤦♂️ 🤦♂️ |
At the very least, removing |
Even if removing CADisplayLink doesn’t address the jittering, we know it contributes to increased power usage. Having it on constantly, especially while using turn-by-turn navigation, could be a real performance issue in itself. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
This issue has been automatically detected as stale because it has not had recent activity and will be archived. Thank you for your contributions. |
See background in #2922 (comment). Makes sense that as the
CADisplayLink
always ticks, we'd be using resources to decide if a frame needs rendered or not, even when idle.@kkaefer Did you measure this at all? How?
/cc @adam-mapbox @tmpsantos
The text was updated successfully, but these errors were encountered: