Skip to content

fix: apply StyleImport config before the first frame - #4443

Merged
mfazekas merged 1 commit into
mainfrom
fix/styleimport-basemap-config
Nov 8, 2026
Merged

mfazekas merged 1 commit into
mainfrom
fix/styleimport-basemap-config

Conversation

@mfazekas

@mfazekas mfazekas commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

Description

Fixes #4438

StyleImport applied its config only after the whole style had loaded, so with config={{lightPreset: 'night'}} the Standard style rendered day frames and then faded to night. It now applies the config as soon as the style root is parsed (StyleDataLoaded with type STYLE), which is the same point where the iOS SDK's MapStyleReconciler applies MapStyle configuration, so the first frame already uses it. Thanks @stianjensen for the analysis in the issue, which pinpointed both the cause and the upstream behavior.

The subscription stays across style changes, so a new styleURL or styleJSON also gets the config before its first frame. This applies to any import id, not just basemap.

Verified on the example app (iOS 26 simulator, Android emulator), counting frames whose map area is day-bright across a first mount and a cached remount: iOS 138 → 0, Android 45 → 0 (before the fix, Android showed about 4 s of day on first mount). Also checked on both platforms: switching between standard, standard-satellite and a styleJSON that imports Standard as other (night from the first frame each time), and unmounting and remounting the import. On iOS, a runtime lightPreset change still animates. On Android it switches in a single recorded frame through the same native setStyleImportConfigProperties call as before; I did not record an unfixed baseline for that case.

Checklist

  • I've read CONTRIBUTING.md
  • I updated the doc/other generated code with running yarn generate in the root folder
  • I have tested the new feature on /example app.
    • In V11 mode/ios
    • In New Architecture mode/ios
    • In V11 mode/android
    • In New Architecture mode/android
  • I added/updated a sample - if a new feature was implemented (/example)

Screenshot OR Video

Before, iOS first mount: day frames, then a fade to night. After: night from the first map frame. Measured from simctl io recordVideo and adb screenrecord captures.

Component to reproduce the issue you're fixing

Tap Mount: on the unfixed build the map shows day frames before fading to night. Unmount and Mount again to check a cached remount.

import React, { useState } from 'react';
import { Button, View, Text } from 'react-native';
import { Camera, MapView, StyleImport } from '@rnmapbox/maps';

const BugReportExample = () => {
  const [mounted, setMounted] = useState(false);
  const [count, setCount] = useState(0);
  return (
    <View style={{ flex: 1, backgroundColor: '#000' }}>
      <View style={{ flexDirection: 'row', alignItems: 'center' }}>
        <Button
          title={mounted ? 'Unmount' : 'Mount'}
          onPress={() => {
            if (!mounted) setCount((c) => c + 1);
            setMounted(!mounted);
          }}
        />
        <Text style={{ color: '#fff' }}>mounts: {count}</Text>
      </View>
      {mounted && (
        <MapView
          key={count}
          style={{ flex: 1 }}
          styleURL="mapbox://styles/mapbox/standard"
        >
          <Camera centerCoordinate={[-74.00597, 40.71427]} zoomLevel={14} />
          <StyleImport id="basemap" existing config={{ lightPreset: 'night' }} />
        </MapView>
      )}
    </View>
  );
};

export default BugReportExample;

Apply the import config when the style root is parsed (StyleDataLoaded with type STYLE) instead of after the whole style loads, the same moment the Mapbox SDKs apply MapStyle configuration. With lightPreset: 'night' the map no longer renders day frames and fades to night.

Fixes #4438
@mfazekas
mfazekas merged commit a0852b9 into main Nov 8, 2026
10 checks passed
@mfazekas
mfazekas deleted the fix/styleimport-basemap-config branch November 8, 2026 09:46

This branch was previously deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]:

1 participant