Skip to content

Android: setOverrideSynchronousUpdate for existing sources#4366

Open
systemed wants to merge 1 commit into
maplibre:mainfrom
systemed:geojson_override_sync
Open

Android: setOverrideSynchronousUpdate for existing sources#4366
systemed wants to merge 1 commit into
maplibre:mainfrom
systemed:geojson_override_sync

Conversation

@systemed

Copy link
Copy Markdown
Contributor

#4092 replaced setGeoJsonSync on Android with a new .withSynchronousUpdate(true) option when creating a new GeoJSONSource.

However, this removed the possibility to use synchronous updates for existing GeoJSON sources defined in the stylesheet. Previously we could write:

val turnSource = map.style?.getSource("turn_highlights") as GeoJsonSource? ?: return
turnSource.setGeoJsonSync(FeatureCollection.fromFeatures(lines))

which is no longer possible.

This PR reinstates this possibility by giving the user the option to override the synchronous updates setting for a GeoJSON source. With this, we can write:

val turnSource = map.style?.getSource("turn_highlights") as GeoJsonSource? ?: return
turnSource.setOverrideSynchronousUpdate(true)
turnSource.setGeoJson(FeatureCollection.fromFeatures(lines))

This fixes #4187 using the approach I described in the comment and subsequently commented on by @louwers. I've chosen to fix it at the code level, rather than the stylesheet level, because this is a matter of client implementation rather than map style - in other words, it's very possible that one client using a given stylesheet might want synchronous updates, and another might not.

I've tested it locally using a special build of cycle.travel's app and it works well for me.

AI disclosure: I wrote the code and text myself, but did ask Claude to verify if I'd missed anything along the way, because it's better at C++ than I am. ;)

@github-actions github-actions Bot added android core Changes that affect the C++ core of MapLibre Native labels Jun 27, 2026
@louwers louwers requested a review from alexcristici July 1, 2026 11:00

@louwers louwers left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, @alexcristici maybe you can also have a look.

@github-actions

github-actions Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Bloaty Results 🐋

Compared to main

    FILE SIZE        VM SIZE    
 --------------  -------------- 
  +0.0% +4.95Ki  +0.0%    +376    TOTAL

Full report: https://maplibre-native.s3.eu-central-1.amazonaws.com/bloaty-results/pr-4366-compared-to-main.txt

Compared to d387090 (legacy)

    FILE SIZE        VM SIZE    
 --------------  -------------- 
   +51% +59.1Mi  +467% +27.9Mi    TOTAL

Full report: https://maplibre-native.s3.eu-central-1.amazonaws.com/bloaty-results/pr-4366-compared-to-legacy.txt

@github-actions

github-actions Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Benchmark Results ⚡

Benchmark                                                     Time             CPU      Time Old      Time New       CPU Old       CPU New
------------------------------------------------------------------------------------------------------------------------------------------
OVERALL_GEOMEAN                                            -0.0007         -0.0002             0             0             0             0

Full report: https://maplibre-native.s3.eu-central-1.amazonaws.com/benchmark-results/pr-4366-compared-to-main.txt

@github-actions

github-actions Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Bloaty Results (iOS) 🐋

Compared to main

    FILE SIZE        VM SIZE    
 --------------  -------------- 
  [ = ]       0  [ = ]       0    TOTAL

Full report: https://maplibre-native.s3.eu-central-1.amazonaws.com/bloaty-results-ios/pr-4366-compared-to-main.txt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

android core Changes that affect the C++ core of MapLibre Native

Projects

None yet

Development

Successfully merging this pull request may close these issues.

withSynchronousUpdate(false) for SourceLayers from StyleJson

2 participants