mapbox / mapbox/mapbox-maps-flutter

[performance] CameraForCoordinateBounds deprecation question

Open
#622 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Dart
Stars
380
Forks
204
PR merge metrics
No merged PRs in 30d

Description

### Explanation
In native SDK, since 11.4.0, `cameraForCoordinateBounds` has been deprecated in favor of `cameraForCoordinates`.

In our app we are drawing some routes and users have the ability to open and close some filters etc. When those filters are opened or closed we need to move the camera to make the whole route visible since the filters hide certain areas of the map. The problem is that the replacement function `cameraForCoordinates`, when used from Flutter side has a significant performance penalty when compared to manually calculating bounds for the route on the Flutter side and passing only the bounds for `cameraForCoordinateBounds`.

### Observation
The tests were done in release mode.
We have checked that for a route consisting of 14000 points, both manually calculating the bounds and getting the camera with `cameraForCoordinateBounds` takes approximately 5ms to complete.
When using `cameraForCoordinates`, we are passing those 14000 points to the native side and we need approximately 200ms to get the camera.

We assume this is not the problem for the native apps, since there is no copy of the points, but for Flutter, this causes significant performance penalty.

We had some ideas for handling it, like for example, getting the cameras for every possibility of opened filters and store them in some local variables to avoid calculation every time the state of the filters change but it doesn't seem like the right way to go about this.

### Question

Since it is only a matter of time when `cameraForCoordinateBounds` will be removed, are there any other ideas for calculating camera for certain points without such a great performance penalty?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the Flutter-side use of cameraForCoordinates and cameraForCoordinateBounds, along with the native SDK deprecation context. Reproduce the release-mode comparison using the reported 14,000-point route; the issue needs a decided alternative or documented guidance before implementation scope is clear.

Written by the indexing model from the issue text.

Assessment

Tech stack
dart, flutter
Domain
mobile, performance
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.