maplibre-react-native icon indicating copy to clipboard operation
maplibre-react-native copied to clipboard

ImageSource fails to load first file uri shown on iOS

Open andrewwardmt opened this issue 5 months ago • 1 comments

Describe and reproduce the Bug

I'm attempting to manage the loading of images from the network myself to intelligently preload images before they are needed. I've found that ImageSource will fail to load the first file path URI it is given on iOS with the following message:

[event]:Style [code]:-1 [message]:Failed to load source myImageSource: 
  • Expected: Using a file path URI as an image source loads that image successfully and displays it.
  • Actual: The image fails to load if it's the first uri that ImageSource attempts.
  • MRE: https://github.com/andrewwardmt/maplibre-image-mre

As a workaround, showing url="pending" and then the actual file URI after 50ms works:

const uri = await fetchImage();
setImage("pending"); // (this is the ImageSource url, see the MRE for the full code)
await sleep(50);
setImage(uri);

Just adding a delay before showing the image doesn't work

@maplibre/maplibre-react-native Version

10.1.6

Which platforms does this occur on?

iOS Simulator and iPhone 14 (iOS 18.3.2)

Which frameworks does this occur on?

Expo

Which architectures does this occur on?

New Architecture

Environment

expo-env-info 1.3.3 environment info:
    System:
      OS: macOS 15.5
      Shell: 5.9 - /bin/zsh
    Binaries:
      Node: 22.13.1 - /opt/homebrew/opt/node@22/bin/node
      npm: 10.9.2 - /opt/homebrew/opt/node@22/bin/npm
      Watchman: 2024.12.02.00 - /opt/homebrew/bin/watchman
    Managers:
      CocoaPods: 1.16.2 - /opt/homebrew/bin/pod
    SDKs:
      iOS SDK:
        Platforms: DriverKit 24.4, iOS 18.4, macOS 15.4, tvOS 18.4, visionOS 2.4, watchOS 11.4
    IDEs:
      Android Studio: 2024.3 AI-243.25659.59.2432.13423653
      Xcode: 16.3/16E140 - /usr/bin/xcodebuild
    npmPackages:
      expo: ~53.0.11 => 53.0.11 
      react: 19.0.0 => 19.0.0 
      react-native: 0.79.3 => 0.79.3 
    Expo Workflow: managed

andrewwardmt avatar Jun 13 '25 13:06 andrewwardmt

By searching for "Failed to load source", I can see the error is being produced here: https://github.com/maplibre/maplibre-native/blob/6e67ebf51dd65b8e2ab0ce3fe899d202ce24fcfc/src/mbgl/style/style_impl.cpp#L349

andrewwardmt avatar Jun 13 '25 13:06 andrewwardmt