-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Avoid animating to the same camera options #5983
Comments
I think from end user perspective immediately would make the most sense. |
I am going the route here of:
I'm doing this with a few reusable viewport and camera equality check routines and some other slight refactoring to ensure that:
Starting with iOS to hit some immediate needs, but will bring this to Android as well. |
Beginning in 4ef336e I am gating each viewport change method on I also abstracted some routines out that we use more than once and created a set of convenience handlers for checking the viewport changes by passing some or all of these parameters. This is just iOS to start. /cc @1ec5 @friedbunny |
I think this is the cruxt of the problem that’s currently affecting user tracking use cases and causing #5833. The fix in 4ef336e will harden us against this kind of issue, but it should be much more tightly scoped to take advantage of the equality functions we already have in the SDK. Every round trip between MGLMapCamera and |
@1ec5 @friedbunny @boundsj I'm trying to think ahead to how I might write tests for these gates and coming up blank. Basically, we want to ensure that the setters are bailing early if the viewport is unchanged. By virtue of the viewport not getting changed, there isn't really anything to measure concretely. Any ideas? 🤔 |
Specifically, it would be nice to be able to determine that either a Core Animation or a core GL transition aren't happening. |
Currently trying something around inspecting |
If you take my advice in 4ef336e#commitcomment-18666523, you could call |
Nice, I like that idea. |
The test approach doesn't work for all of the setters, but it does for a basic camera set with a completion handler, which is a pretty good start. Confirmed that it fails on current |
On a delay. Callback APIs should be async always, not sometimes async and sometimes immediate. In this case, calling the callback immediately sets users up for a stack overflows reminiscent of #5833 in the case that a completion handler: a) re-triggers the animation |
I agree #2259 should be fixed in core, but at the same time, I don’t agree that a call to
Even if we implement (3), we still need (1) because setters like |
Some of what @1ec5 says is why I was inclined to first tackle this in iOS (making sure it solves our downstream issues), then apply the principles to core (while also possibly removing some of the iOS code). Things exactly like user tracking mode, or UI element coordination, are why this needs to happen at least in some part at the platform level. |
It's not entirely complete, since I have some other pending refactoring work which also makes use of this, but I introduced a convenience function called This also moves instances of the always lovely Feedback welcome @jfirebaugh @1ec5. |
#7125 is a more tightly scoped take to this problem. It pushes the redundancy checks further down to the three bottlenecks where we call into mbgl to modify the viewpoint. I think my approach is justified because:
Additionally, #7125 triggers the completion handler on a delay in the case of a redundant camera change, per #5983 (comment). |
Why not now? |
Just flagging that we should make sure to avoid a repeat of #7098 here if we're pushing this deeper into core - the Node.js bindings rely on a stateless camera that resets to default values for consecutive calls to |
Because there would still be some knots (like the KVO willChange/didChange calls) to untangle so close to a release, with the risk of regressing delegate method coalescing that we've been unable to UI test reliably. Also because the right fix in mbgl has implications for the Android SDK, which is even closer to release. See #5833 (comment). |
This issue – insignificant camera changes that trigger animations in-place – is most likely an edge case that only occurs for instance when the user is stopped at a traffic light and GPS readings bounce around slightly. #7236 is related and much more acute. We’ll have to do a bit more profiling to know exactly where the issue lies. |
If you attempt to change the camera to an
mbgl::CameraOptions
that’s identical to the currentCameraOptions
,mbgl::Transform
still goes through the entire animation machinery. We do avoid modifying theTransformState
in that case, but by then it’s too late: we’ve already kicked off an animation timer and all the calculations for each step of the animation. The animation timer updates the map on a schedule regardless of whether the transform state changes.There are multiple places where we can short-circuit the animation, and we should consider all of them to avoid severe energy consumption in navigation use cases, which require constant animation.
Incidentally, when we bail for a no-op animation, should the completion callback by called immediately, or still on a delay?
/cc @kkaefer @friedbunny
The text was updated successfully, but these errors were encountered: