Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RasterLayer flicker #800

Open
M2dL1fe opened this issue Dec 10, 2024 · 8 comments
Open

RasterLayer flicker #800

M2dL1fe opened this issue Dec 10, 2024 · 8 comments

Comments

@M2dL1fe
Copy link

M2dL1fe commented Dec 10, 2024

class TestMapView extends StatefulWidget {
  const TestMapView({super.key});

  @override
  State<StatefulWidget> createState() => TestMapState();
}

class TestMapState extends State<TestMapView> {
  MapboxMap? controller;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: const Text("Mapbox Test")),
      body: MapWidget(
        styleUri: "0000000000000000000000",
        cameraOptions: CameraOptions(center: Point(coordinates: Position(174.7633, -36.8485)), zoom: 12),
        onMapCreated: (controller) {
          this.controller = controller;
        },
        onMapLoadedListener: (mapLoadedEventData) async {
          const sourceId = "sourceId-test";
          const layerId = "layerId-test";
          const url = "https://wslgis.water.co.nz/arcgis/rest/services/Custom/CustomPublic/MapServer/export?dpi=96&transparent=true&format=png32&layers=show:-1,-1,-1,8&bbox={bbox-epsg-3857}&bboxSR=3857&imageSR=3857&size=256,256&f=image";
          await controller?.style.addSource(RasterSource(id: sourceId, tiles: [url], tileSize: 256));
          var layer = RasterLayer(id: layerId, sourceId: sourceId);
          await controller?.style.addLayer(layer);
        },
      ),
    );
  }

  @override
  void dispose() {
    controller?.clearData();
    super.dispose();
  }

}

RasterLayer flicker, then disappear.
No problem with Web access

Dec-10-2024.15-37-18.mp4

s

@evil159
Copy link
Contributor

evil159 commented Dec 10, 2024

@M2dL1fe I get a lot of "Resource not found" errors when running the sample you provided:

[mapbox-maps-flutter] [Error, maps-core]: {}[General]: The resource `https://wslgis.water.co.nz/arcgis/rest/services/Custom/CustomPublic/MapServer/export?dpi=96&transparent=true&format=png32&layers=show:-1,-1,-1,8&bbox=10018754.17139462,-10018754.171394622,20037508.342789245,0&bboxSR=3857&imageSR=3857&size=256,256&f=image` not found

@M2dL1fe
Copy link
Author

M2dL1fe commented Dec 10, 2024

The same Url, using JS can be perfectly displayed

@evil159
Copy link
Contributor

evil159 commented Dec 11, 2024

@M2dL1fe How do you use it in JS? I see nothing on the map with this code:

    mapboxgl.accessToken = 'YOUR_MAPBOX_ACCESS_TOKEN';
    const map = new mapboxgl.Map({
        container: 'map', // container ID
        style: {
            'version': 8,
            'sources': {
                'raster-tiles': {
                    'type': 'raster',
                    'tiles': ['https://wslgis.water.co.nz/arcgis/rest/services/Custom/CustomPublic/MapServer/export?dpi=96&transparent=true&format=png32&layers=show:-1,-1,-1,8&bbox={bbox-epsg-3857}&bboxSR=3857&imageSR=3857&size=256,256&f=image'],
                    'tileSize': 256
                }
            },
            'layers': [
                {
                    'id': 'simple-tiles',
                    'type': 'raster',
                    'source': 'raster-tiles',
                    'minzoom': 0,
                    'maxzoom': 22
                }
            ]
        },
        center: [-74.5, 40], // starting position
        zoom: 2 // starting zoom
    });

@M2dL1fe
Copy link
Author

M2dL1fe commented Dec 11, 2024

longitude: 174.7633 latitude: -36.8485 zoom: 12 , country :New zeland @evil159

@evil159
Copy link
Contributor

evil159 commented Dec 11, 2024

@M2dL1fe Thank you for clarifying the tile location! We've made an initial pass over this issue and it appears to be a bug on our side.
The tile server(wslgis.water.co.nz) responds with a rather odd "Cache-Control" configuration private, must-revalidate, max-age=0, which makes the tile response stale from the get-go thus triggering concequent successive attempts to fetch the same resource. We do seem to have a bug with handling 304 Not Modified responses in this case. However, one thing to check on the server side would the max-age value, having it at 0 looks like a misconfiguration.

@evil159
Copy link
Contributor

evil159 commented Dec 11, 2024

Ticket for tracking this internally https://mapbox.atlassian.net/browse/MAPSNAT-2617

@M2dL1fe
Copy link
Author

M2dL1fe commented Dec 12, 2024

@M2dL1fe Thank you for clarifying the tile location! We've made an initial pass over this issue and it appears to be a bug on our side. The tile server(wslgis.water.co.nz) responds with a rather odd "Cache-Control" configuration private, must-revalidate, max-age=0, which makes the tile response stale from the get-go thus triggering concequent successive attempts to fetch the same resource. We do seem to have a bug with handling 304 Not Modified responses in this case. However, one thing to check on the server side would the max-age value, having it at 0 looks like a misconfiguration.

The Url provided by the government, we have no right to change

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

No branches or pull requests

2 participants