Flutter_map: Tiles render eratically in release build only

Created on 14 Dec 2019  路  12Comments  路  Source: fleaflet/flutter_map

For a few months, I've had no problem rendering map tiles, doing extensive testing both in the emulator and on a variety of real devices. Now that I'm starting alpha tests, I've been doing release builds rather than debug builds. For reasons I can't explain, tiles often don't render.

Sometimes I'll open the app and it will be fine. Sometimes tiles won't render at all, giving a grey background. Sometimes it will work at one zoom level and not another. Markers and a Polyline layer always scontinue to render correctly. If I substitute a tileProvider, I can see that the getImage method is returning correctly even when the tiles don't render.

Does anybody have suggestions on where to look for the problem?

bug

Most helpful comment

For what it's worth, this was happening for me on Android. Both in the emulator and on my Pixel. I haven't tried it on iPhone, but there were no network errors. Indeed, the network was my first suspicion, which is why I logged requests like this:

class LoggingCachedNetworkTileProvider extends fm.CachedNetworkTileProvider {
  @override
  ImageProvider getImage(Coords<num> coords, TileLayerOptions options) {
    print('getting image $coords');
    var result = super.getImage(coords, options);
    print('got $result');
    return result;
  }

Tiles were definitely getting fetched; they just weren't being reliably rendered.

All 12 comments

I've created a minimal reproducible example you can see here. For me, it never renders in release mode, not even sporadically (note that the example only includes a TileLayer).

Isn't that a provider issue ? Which one you use ?

I'm not sure who you're asking, @kleeb, but if it's me, I'm using MapBox. My setup looks like this:

    var mapLayers = <fm.LayerOptions>[
      new fm.TileLayerOptions(
        urlTemplate: "https://api.tiles.mapbox.com/v4/"
            "{id}/{z}/{x}/{y}@2x.png?access_token={accessToken}",
        additionalOptions: {
          'accessToken': 'MYTOKEN',
          'id': 'mapbox.streets',
        },
      ),
    ];

I see that @DamianoMagrini in his example (thanks, Damiano!) has the same issue with OSM tiles.

have you tried vector version of Mapbox ?
https://pub.dev/packages/mapbox_gl

it should work much more smoothly

I have, @kleeb, and it has its own problems. Not quite as bad as this bug, but assuming this gets fixed, I'd rather stick with this package.

I think they worked on it quite heavily. It works really proper in the latest 0.0.4 version

I'm happy you've found something you're excited about. But perhaps on the discussion of this bug, we could stick to this bug?

I can't reproduce this issue. I downloaded https://github.com/DamianoMagrini/flutter-maps-does-not-render-mre and installed it on my iPhone in release mode - can you provide more details about your device / network? Are there any network failures happening?

For what it's worth, this was happening for me on Android. Both in the emulator and on my Pixel. I haven't tried it on iPhone, but there were no network errors. Indeed, the network was my first suspicion, which is why I logged requests like this:

class LoggingCachedNetworkTileProvider extends fm.CachedNetworkTileProvider {
  @override
  ImageProvider getImage(Coords<num> coords, TileLayerOptions options) {
    print('getting image $coords');
    var result = super.getImage(coords, options);
    print('got $result');
    return result;
  }

Tiles were definitely getting fetched; they just weren't being reliably rendered.

@wpietri , did find any solution ? I can reproduce this issue only with a real an droid device.
It's working in the emulators...

@vianneyriotte I did not. Right now I'm evaluating other mapping libraries.

One thing I spotted recently, is that you can end up with a different AndroidManifest.xml file for debug and live mode.

In my case, my debug manifest had internet enabled, but my live file didn't (I had never dabbled with either)..

<uses-permission android:name="android.permission.INTERNET" />

So what was happening, when I went to release mode, the app was just using the cached tiles on the device only. Changing the manifest file fixed it.

Naturally, it may not be this problem also, but it may help others.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

igaurab picture igaurab  路  5Comments

rktvsiim picture rktvsiim  路  5Comments

garrrettt picture garrrettt  路  4Comments

EdHubbell picture EdHubbell  路  4Comments

palicka picture palicka  路  4Comments