You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Aug 8, 2023. It is now read-only.
Repository navigation
This repository was archived by the owner on Aug 8, 2023. It is now read-only.
Performance regression between iOS 0.5.2 and 0.5.3 #1975
I've noticed a performance regression between iOS 0.5.2 and 0.5.3. I have a UI element which acts as a scrubber along a polyline (video here). I use a custom animation, driven by a CADisplayLink, to set the zoom and centre coordinate of the map every frame using a 3D spring behaviour.
In 0.5.2, the labels don't redraw until the animation stops, and during the animation the movement is smooth.
In 0.5.3, if the animation changes the zoom to the extent that the labels are due for refresh, it becomes jerky. If you pause the movement long enough for the labels to redraw, it becomes smooth again.
This sounds like it would be related to @brunoabinader's label work in #1548.
We have a fix for that in #1928 (commit 5e2f3b1), which landed on version 0.5.4. @tomtaylor, is it possible to test it against version 0.5.4 instead of 0.5.3? Also, I'd love to reproduce the custom animation if you have it handy.
Thanks - I'm away from my machine at the moment, but I'm pretty confident I tested against 0.5.4 with the same results. I'll get you the animation code when I get back.
On 1 Aug 2015, at 09:03, Bruno de Oliveira Abinader [email protected] wrote:
This sounds like it would be related to @brunoabinader's label work in #1548.
We have a fix for that in #1928, which landed on version 0.5.4. @tomtaylor, is it possible to test it against version 0.5.4 instead of 0.5.3? Also, I'd love to reproduce the custom animation if you have it handy.
—
Reply to this email directly or view it on GitHub.
@brunoabinader I just managed to try this out on 2.1.0-pre.1, and I don't think it's quite fixed yet. I recorded a video through Quicktime from my 5s, which shows what I'm experiencing. For context, I'm touching on the scrubber at the bottom to zoom in at that point on the route, driven by the animation code I shared previously. Let me know if I can give you any more information.
For those who want to know more: the first clue was @jfirebaugh 's comment about de-duplicating updates. Then the second clue was the erratic way that the GL view was being driven when we were doing updates, as shown by my investigation into presentRenderbuffer. I started thinking: why are we trying to draw at 60 FPS? Then I went to rate-limit the app, and I realized: we weren't obeying any kind of smoothing or rate limiting at all. We were literally just rendering as fast (or as slow) as we could. Anytime anyone called [MGLMapView invalidate], we just did a setNeedsDisplay and the system responded by drawing as fast as it could. That is a super bad idea for a number of reasons, not least of which is that it causes uneven frame rate and stuttering - which is exactly what we were seeing! I honestly thought we were being driven by a GLKViewController, but of course, I understand why we're not, now; it's obvious - we want to stop rendering when nothing is happening. So we need to roll our own GLKViewController using CADisplayLink, but wire it up so that it only tries to render iff a full 1/30 of a second has passed and we've asked for a render. Add in a little thread-safety and that's the whole change.
Et voila, the app stops rendering when we don't need to, and renders smooth as butter when we want it to.
There's only one final detail to think about, and that's our desired frame rate. Right now I capped it at 30. That works pretty well on almost all devices and in 95% of all cases. We may have select reasons to want to go up or down, though, in specific situations. For example on an older iPod touch or a crappy old iPhone, we may want it to be 20. And on a very fast machine under certain circumstances we may want to shoot for 60. I would also be in favor of making this a user-controllable setting, if we think that's wise.
It's worth mentioning that, in my limited testing on an iPod Touch 6G, this change seems to improve performance across the board; at least, perceived performance. Pans and zooms are much smoother to the eye.
@adam-mapbox - interesting so part of the problem is that we are too slow for 60fps? perhaps I should rethink #2773 and aim for capped 30fps on Android too
Android used to be happily 60fps so perhaps things in core GL have gone backwards in the last year as far as performance goes. Either that or out GL styles have become to intensive.
I honestly thought we were being driven by a GLKViewController, but of course, I understand why we're not
@adam-mapbox I should add that if at all possible, I would use GLKViewController, but we want to remain a simple UIView derivative that devs drop in, and not dictate that they use a certain type of view controller. This is to be more like MKMapView.
Other, similar issues have come up in past (see search) but we want to remain easy for devs to integrate as a standalone view.
Makes sense. I also don't know how we would use GLKViewController in the manner that we ended up needing to; it isn't designed to work the way that we need.
Sent from my iPhone
On Nov 4, 2015, at 11:06 AM, Justin R. Miller [email protected] wrote:
I honestly thought we were being driven by a GLKViewController, but of course, I understand why we're not
@adam-mapbox I should add that if at all possible, I would use GLKViewController, but we want to remain a simple UIView derivative that devs drop in, and not dictate that they use a certain type of view controller. This is to be more like MKMapView.
Other, similar issues have come up in past (see search) but we want to remain easy for devs to integrate as a standalone view.
—
Reply to this email directly or view it on GitHub.
Activity
friedbunny commentedon Aug 1, 2015
This sounds like it would be related to @brunoabinader's label work in #1548.
/cc @incanus
brunoabinader commentedon Aug 1, 2015
We have a fix for that in #1928 (commit 5e2f3b1), which landed on version
0.5.4. @tomtaylor, is it possible to test it against version0.5.4instead of0.5.3? Also, I'd love to reproduce the custom animation if you have it handy.tomtaylor commentedon Aug 1, 2015
Thanks - I'm away from my machine at the moment, but I'm pretty confident I tested against 0.5.4 with the same results. I'll get you the animation code when I get back.
tomtaylor commentedon Aug 2, 2015
OK, here's the animation driver code: https://gist.github.com/tomtaylor/91d29f47f281b9d96fcd
And I can confirm the same behaviour on 0.5.4. Let me know if I can give you any more info.
brunoabinader commentedon Aug 5, 2015
@tomtaylor I just merged #1979 into
master; could you please check?tomtaylor commentedon Aug 5, 2015
@brunoabinader happy to, do you think you could make me a new podspec file, pointing to a precompiled .zip version?
tomtaylor commentedon Aug 26, 2015
@brunoabinader I just managed to try this out on 2.1.0-pre.1, and I don't think it's quite fixed yet. I recorded a video through Quicktime from my 5s, which shows what I'm experiencing. For context, I'm touching on the scrubber at the bottom to zoom in at that point on the route, driven by the animation code I shared previously. Let me know if I can give you any more information.
https://s3-eu-west-1.amazonaws.com/files.tomtaylor.co.uk/data/mapbox-lag.mov
(On the flip side, it seems to perform even better when all the labels have rendered!)
tomtaylor commentedon Aug 28, 2015
@brunoabinader @incanus should I open a new issue for this?
incanus commentedon Sep 1, 2015
Nope, we'll re-investigate this here.
41 remaining items
adam-mapbox commentedon Nov 4, 2015
Hallelujah! The promised land arrives. I have a fix. It's simple, it's correct, and it fixes the problem, I do believe. Here it is: #2922. Enjoy.
@incanus @jfirebaugh @tomtaylor @brunoabinader @kkaefer @1ec5
For those who want to know more: the first clue was @jfirebaugh 's comment about de-duplicating updates. Then the second clue was the erratic way that the GL view was being driven when we were doing updates, as shown by my investigation into presentRenderbuffer. I started thinking: why are we trying to draw at 60 FPS? Then I went to rate-limit the app, and I realized: we weren't obeying any kind of smoothing or rate limiting at all. We were literally just rendering as fast (or as slow) as we could. Anytime anyone called
[MGLMapView invalidate], we just did asetNeedsDisplayand the system responded by drawing as fast as it could. That is a super bad idea for a number of reasons, not least of which is that it causes uneven frame rate and stuttering - which is exactly what we were seeing! I honestly thought we were being driven by aGLKViewController, but of course, I understand why we're not, now; it's obvious - we want to stop rendering when nothing is happening. So we need to roll our ownGLKViewControllerusingCADisplayLink, but wire it up so that it only tries to render iff a full 1/30 of a second has passed and we've asked for a render. Add in a little thread-safety and that's the whole change.Et voila, the app stops rendering when we don't need to, and renders smooth as butter when we want it to.
There's only one final detail to think about, and that's our desired frame rate. Right now I capped it at 30. That works pretty well on almost all devices and in 95% of all cases. We may have select reasons to want to go up or down, though, in specific situations. For example on an older iPod touch or a crappy old iPhone, we may want it to be 20. And on a very fast machine under certain circumstances we may want to shoot for 60. I would also be in favor of making this a user-controllable setting, if we think that's wise.
It's worth mentioning that, in my limited testing on an iPod Touch 6G, this change seems to improve performance across the board; at least, perceived performance. Pans and zooms are much smoother to the eye.
ljbade commentedon Nov 4, 2015
@adam-mapbox - interesting so part of the problem is that we are too slow for 60fps? perhaps I should rethink #2773 and aim for capped 30fps on Android too
ljbade commentedon Nov 4, 2015
Android used to be happily 60fps so perhaps things in core GL have gone backwards in the last year as far as performance goes. Either that or out GL styles have become to intensive.
incanus commentedon Nov 4, 2015
Proposed solution discussion over in #2922 (comment).
Fix #1975 - improve animation fluidity and response
incanus commentedon Nov 4, 2015
@adam-mapbox I should add that if at all possible, I would use
GLKViewController, but we want to remain a simpleUIViewderivative that devs drop in, and not dictate that they use a certain type of view controller. This is to be more likeMKMapView.Other, similar issues have come up in past (see search) but we want to remain easy for devs to integrate as a standalone view.
fezzik21 commentedon Nov 4, 2015
Makes sense. I also don't know how we would use GLKViewController in the manner that we ended up needing to; it isn't designed to work the way that we need.
Sent from my iPhone
Fix mapbox#1975 - improve animation fluidity and response