Skip to content

Warning database has been locked for 0:00:10.000000. #752

Closed

Description

@Swepilot

When loading several TileLayerOptions at the same time, using the default CachedNetworkTileProvider I get the warning "Warning database has been locked for 0:00:10.000000." I suspect this is caused by cached_network_image or rather flutter_cache_manager. Loading only a few layers at the same time does not produce this problem.

Anyone had this and able to provide a solution/workaround (except not loading several layers...)

Activity

  1. maRci002 commented on Sep 23, 2020

    @maRci002
    Contributor

    CachedNetworkTileProvider uses Flutter's CachedNetworkImageProvider and if they use sqlite as default cache manager then it could happen because images' bytes aren't batched in one transaction since they don't know about each other since images returns from internet at different time.

    Try to add some layers a little later, like this:

      final layers = <LayerOptions>[];
    
      @override
      void initState() {
        super.initState();
    
        layers.addAll(<LayerOptions>[
          TileLayerOptions(),
          TileLayerOptions(),
          TileLayerOptions(),
          ...
        ]);
    
        Timer(const Duration(milliseconds: 50), () {
          layers.addAll(<LayerOptions>[
            TileLayerOptions(),
            TileLayerOptions(),
            TileLayerOptions(),
            ...
          ]);
          setState(() {});
        });
    
        Timer(const Duration(milliseconds: 100), () {
          layers.addAll(<LayerOptions>[
            TileLayerOptions(),
            TileLayerOptions(),
            TileLayerOptions(),
            ...
          ]);
          setState(() {});
        });
      }
    
      @override
      Widget build(BuildContext context) {
        ...
        child: FlutterMap(
          layers: layers,
        ),
        ...
      }

    However if you move around map this can still happen and above solution may not solve the above warning.

  2. Swepilot commented on Sep 24, 2020

    @Swepilot
    Author

    Thanks again, very supportive as always. Yeah, it happens when moving the map around. I'll see what I can do to improve this.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions