Skip to content

[Bug]: Android app crashes - createPack() throwing error while downloading and app crashes on getPacks() #4230

Closed as not planned

Description

@nv-mahesh

Mapbox Version

11.8.0

React Native Version

0.77.0

Platform

Android

@rnmapbox/maps version

10.1.45

Standalone component to reproduce

import React, { useEffect } from 'react';
import MapboxGL, {
  MapView,
  ShapeSource,
  LineLayer,
  Camera,
} from '@rnmapbox/maps';

const DownloadOfflineMap = () => {
  const RegionId = 'offline-region-1';

  const bounds = [
    [73.90, 18.45], // southwest [longitude, latitude]
    [74.05, 18.55], // northeast [longitude, latitude]
  ];

  const offlinePackOptions = {
    name: RegionId,
    styleURL: MapboxGL.StyleURL.Street,
    bounds,
    minZoom: 10,
    maxZoom: 15,
    metadata: {
      regionId: RegionId,
      downloadedAt: new Date().toISOString(),
      version: '1.0',
    },
  };

  useEffect(() => {
    createPack();
  }, []);

  const createPack = async () => {
    try {
      await MapboxGL.offlineManager.createPack(
        offlinePackOptions,
        (offlineRegion, status) =>
          console.log('Download progress:', status),
        (error) =>
          console.error('Failed to download region:', error)
      );
    } catch (error) {
      console.error('Create pack error:', error);
    }
  };

  return null; // No UI rendered
};

export default DownloadOfflineMap;

Observed behavior and steps to reproduce

For offline usage, we create and download regions using MapboxGL.offlineManager.createPack(), and then access the downloaded regions using MapboxGL.offlineManager.getPacks() to display the map and calculate routes in offline mode.
This flow works correctly on iOS — the region downloads successfully, and we can view the map offline without issues.
However, on Android, createPack() throws an error during the download process, and the offline packs are not downloaded completely. Because of this incomplete download, the app crashes when getPacks() is called while trying to open the downloaded region.

Steps to Reproduce

  • Integrate rnmapbox/maps into a React Native project
  • Configure Mapbox access token and initialize the Mapbox map
  • Define a region (bounds, zoom levels, style URL) for offline download
  • Call MapboxGL.offlineManager.createPack() to start downloading the offline region
  • Observe that the download starts but fails or throws an error on Android
  • Navigate to the screen where offline regions are loaded
  • Call MapboxGL.offlineManager.getPacks() to retrieve downloaded packs
  • App crashes on Android because the offline pack is partially downloaded

Expected behavior

  • createPack() should successfully download the offline region on Android
  • getPacks() should return only fully downloaded packs
  • Offline maps and route calculation should work without crashes

Notes / preliminary analysis

No response

Additional links and references

No response

Activity

  1. changed the title [-][Bug]: Android app crashes on getPacks() and createPack() throwing error while downloading[/-] [+][Bug]: Android app crashes - createPack() throwing error while downloading and app crashes on getPacks()[/+] on Jun 17, 2026
  2. mfazekas commented on Jul 5, 2026

    @mfazekas
    Contributor

    Thanks for the report. We tried to reproduce this on Android and were not able to trigger the crash on the current version.

    What we tested (Android emulator, @rnmapbox/maps current main (d4452ff), using your exact params — StyleURL.Street, bounds [[73.90, 18.45], [74.05, 18.55]], minZoom: 10, maxZoom: 15):

    1. Happy path: createPack() downloaded all resources to 100% (complete), no error. getPacks() afterwards returned the pack fine, no crash.
    2. Interrupted download: we started a large uncached region and cut the network mid-download. The createPack error callback fired (this matches your "createPack throws an error during download"), leaving a partial/errored region in the tile store.
    3. getPacks() on that partial/errored pack: returned the packs cleanly — no crash, app stayed alive.

    A couple of things worth noting:

    • A failed/aborted download surfacing via the errorListener callback is expected — that's the third argument to createPack, it's how download errors are reported. It isn't itself the crash.
    • We could not reproduce a crash in getPacks() even with a partially-downloaded pack present.

    You're on 10.1.45, which is quite old. Could you:

    1. Upgrade to the latest 10.3.x and re-test — there's a good chance this is already resolved.
    2. If it still crashes, we really need the actual error and crash trace to diagnose, since neither is in the report:
      • the error object passed to your errorListener (or logged by your console.error('Failed to download region', err))
      • the full native crash stacktrace from adb logcat at the moment getPacks() crashes.

    Reproducer we used, in case you want to check it against your setup:

    Issue4230Repro.tsx
    import { useState } from 'react';
    import Mapbox, { MapView, Camera, offlineManager } from '@rnmapbox/maps';
    import { Button, ScrollView, Text, View } from 'react-native';
    
    const RegionId = 'offline-region-1';
    const bounds: [[number, number], [number, number]] = [
      [73.9, 18.45], // southwest [lng, lat]
      [74.05, 18.55], // northeast [lng, lat]
    ];
    
    export default function Issue4230Repro() {
      const [log, setLog] = useState<string[]>([]);
      const append = (line: string) => {
        console.log('[4230]', line);
        setLog((l) => [...l, line]);
      };
    
      const createPack = async () => {
        try {
          append('createPack: start');
          await offlineManager.createPack(
            {
              name: RegionId,
              styleURL: Mapbox.StyleURL.Street,
              bounds,
              minZoom: 10,
              maxZoom: 15,
              metadata: { regionId: RegionId, version: '1.0' },
            },
            (_r, status) => append(`progress: ${JSON.stringify(status)}`),
            (err) => append(`ERROR callback: ${JSON.stringify(err)}`),
          );
          append('createPack: resolved');
        } catch (e) {
          append(`createPack THREW: ${String(e)}`);
        }
      };
    
      const getPacks = async () => {
        try {
          append('getPacks: start');
          const packs = await offlineManager.getPacks();
          append(`getPacks: got ${packs.length} pack(s)`);
        } catch (e) {
          append(`getPacks THREW: ${String(e)}`);
        }
      };
    
      return (
        <View style={{ flex: 1 }}>
          <Button title="1. Create Pack" onPress={createPack} />
          <Button title="2. Get Packs" onPress={getPacks} />
          <Button title="Reset DB" onPress={() => offlineManager.resetDatabase()} />
          <ScrollView style={{ maxHeight: 220 }}>
            {log.map((l, i) => (
              <Text key={i} style={{ fontSize: 11 }}>{l}</Text>
            ))}
          </ScrollView>
          <MapView style={{ flex: 1 }} styleURL={Mapbox.StyleURL.Street}>
            <Camera zoomLevel={10} centerCoordinate={[73.97, 18.5]} />
          </MapView>
        </View>
      );
    }
  3. mfazekas commented on Oct 12, 2026

    @mfazekas
    Contributor

    Closing as we couldn't reproduce this on current main and haven't heard back. If you still see the crash on the latest release, please reopen with a standalone reproducer.

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions