Skip to content
This repository was archived by the owner on Aug 8, 2023. It is now read-only.
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

Closed

Description

@tomtaylor

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.

Let me know if you need any more information.

Activity

  1. added
    iOS
    performance
    on Aug 1, 2015
  2. friedbunny commented on Aug 1, 2015

    @friedbunny
    Contributor

    This sounds like it would be related to @brunoabinader's label work in #1548.

    /cc @incanus

  3. brunoabinader commented on Aug 1, 2015

    @brunoabinader
    Contributor

    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.

  4. tomtaylor commented on Aug 1, 2015

    @tomtaylor
    Author

    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.

  5. tomtaylor commented on Aug 2, 2015

    @tomtaylor
    Author

    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.

  6. brunoabinader commented on Aug 5, 2015

    @brunoabinader
    Contributor

    @tomtaylor I just merged #1979 into master; could you please check?

  7. tomtaylor commented on Aug 5, 2015

    @tomtaylor
    Author

    @brunoabinader happy to, do you think you could make me a new podspec file, pointing to a precompiled .zip version?

  8. tomtaylor commented on Aug 26, 2015

    @tomtaylor
    Author

    @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!)

  9. tomtaylor commented on Aug 28, 2015

    @tomtaylor
    Author

    @brunoabinader @incanus should I open a new issue for this?

  10. incanus commented on Sep 1, 2015

    @incanus
    Contributor

    Nope, we'll re-investigate this here.

  11. 41 remaining items

  12. adam-mapbox commented on Nov 4, 2015

    @adam-mapbox
    Contributor

    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 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.

  13. ljbade commented on Nov 4, 2015

    @ljbade
    Contributor

    @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

  14. ljbade commented on Nov 4, 2015

    @ljbade
    Contributor

    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.

  15. incanus commented on Nov 4, 2015

    @incanus
    Contributor

    Proposed solution discussion over in #2922 (comment).

  16. added a commit that references this issue on Nov 4, 2015
    36d90ea
  17. incanus commented on Nov 4, 2015

    @incanus
    Contributor

    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.

  18. fezzik21 commented on Nov 4, 2015

    @fezzik21

    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.

  19. added a commit that references this issue on Nov 6, 2015
    92e1759
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

iOSperformance

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions