Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Performance issue - Main isolate is blocked when encoding geojsonFeature #366

Open
T-moz opened this issue Jan 13, 2024 · 4 comments · May be fixed by #367
Open

Performance issue - Main isolate is blocked when encoding geojsonFeature #366

T-moz opened this issue Jan 13, 2024 · 4 comments · May be fixed by #367
Labels
bug Something isn't working

Comments

@T-moz
Copy link

T-moz commented Jan 13, 2024

Before sending geojsonFeature through the method channel, the data is encode.
Ex:
Untitled-8

the function jsonEncode is synchronous, and if the is a lot of data, like a line of 40k points, the main isolate can be blocked.

This can lead to a UI freezed of n-seconds on the Flutter side.

See FlameChart:
Untitled-9

@T-moz T-moz linked a pull request Jan 13, 2024 that will close this issue
@m0nac0
Copy link
Collaborator

m0nac0 commented Jan 14, 2024

A spontaneous idea (not saying this is necessarily better, but might be simpler): could we just expose an ("advanced") variant of the method that accepts a pre-encoded string, such that library consumers can decide how they want to do the json encode (e.g. on another isolate)

@T-moz
Copy link
Author

T-moz commented Jan 14, 2024

A spontaneous idea (not saying this is necessarily better, but might be simpler): could we just expose an ("advanced") variant of the method that accepts a pre-encoded string, such that library consumers can decide how they want to do the json encode (e.g. on another isolate)

Yes this would also work, and I don't see any performances differences between the two solutions.
I think the direction we have to choose is how do you want the FlutterMaplibre API to be design.

  • Should it be a large API, with many optimised and specialised methods ? (like updateLine and updatesLines).
  • Or should it be a less wide API, with a lot of flexibility ? (Like exposing a method setFeatures that accept an encoded string, and the package's user is responsible for the encoding).
  • Or maybe something else, we can ask four outside feedbacks.

My point of view, is that the package maplibre_gl should be a "deep module". Which means that the API exposed should not be very wide, and should handle most of the complexity.

@T-moz
Copy link
Author

T-moz commented Jan 14, 2024

Should it be a large API, with many optimised and specialised methods ? (like updateLine and updatesLines).

I even think that updateLine can be remove and replace by updateLines.
Package's users could still update one line, and they would be encourage to batch updates.

The same goes for other methods.

@T-moz
Copy link
Author

T-moz commented Jan 30, 2024

@m0nac0 I'm staring to think that your idea is better.
Because jsonEncode takes time, but decoding a polyline string, then adapting to latlng, and then converting to geojson also takes a lot of time.

Package user that display list of complexe polylines, should be able to do all that with one compute. And for that, the package needs to expose a lowLevel method, that accept encodedGeoJson.

I will try to expose a method addEncodedGeoJsonSource 🤞

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants