FMTC Docs
Project Links💝 Support Me
v8
v8
  • flutter_map_tile_caching
  • Is FMTC Right For Me?
  • Get Started
    • Quickstart
    • Installation
    • Additional Setup
    • Example Application
  • Usage
    • Initialisation
    • Using Roots & Stores
      • Management
      • Statistics
      • Metadata
      • Recovery
      • Migrator (v6 -> v7)
    • flutter_map Integration
    • Global Settings
    • Full API Reference
  • Bulk Downloading
    • Introduction
    • 1️⃣Create A Region
    • 2️⃣Prepare For Downloading
    • 3️⃣Start In Foreground
      • Buffering
      • 4️⃣Listen For Progress
    • 3️⃣Start In Background
      • Limitations
    • Cancel Download
  • Import & Export
    • Introduction
    • Importing
    • Exporting
  • Migration
    • v7 -> v8 Migration
    • v6 -> v7 Migration
  • Known Issues
  • Credits
  • flutter_map Docs
Powered by GitBook

© Luka Stillingfleet (JaffaKetchup)

On this page
  • Without Buffering
  • With Buffering
  • Using Buffering

Was this helpful?

Export as PDF
  1. Bulk Downloading
  2. Start In Foreground

Buffering

Available since v7

Buffering reduces the total download time, at the expense of increased memory usage.

Without Buffering

Without buffering, every tile is written directly to the database before continuing to the next one (within each simultaneous thread). This requires a write transaction for every tile, which are relatively slow. Without buffering, the database write speed is usually the limiting factor in the download speed.

With Buffering

To avoid this problem, buffering can be used. Tiles are written to an intermediate buffer before being written to the database, in bulk. This means a transaction is only needed for every bulk write operation, which can lead to huge speed improvements (>2x is possible). However, there are two major cons that you should consider before implementing this in your application:

  • Memory usage increases significantly When in use, the Memory usage graph within DevTools will likely look like a sawtooth wave. The peak memory usage may be too high for some devices, so you should consider your audience.

  • An app crash can lead to data loss Tiles in the buffer will be lost in the event of an app crash, meaning their download will have been wasted. Tiles that have been written previously will not be lost.

It may be appropriate to leave the decision up to each user individually. In this case, ensure you thoroughly explain these cons to the user, to allow them to make an informed decision. Alternatively, you might make a decision based on the platform. Desktop platforms are likely to have enough RAM capable of holding the buffer, whereas some older mobile devices may struggle.

Using Buffering

Buffering is disabled by default, and can be enabled in the startForeground method call (the property is not part of the DownloadableRegion).

Buffering is not supported by background downloading, as maximizing speed isn't usually a priority for background downloads.

Buffering can be defined by one of two types of limit, shown below. Neither has a disadvantage in terms of performance, but memory allows finer grain control, at the expense of being less obvious to the user.

  • Memory (buffer bytes size)

  • Tiles (buffer length)

PreviousStart In ForegroundNextListen For Progress

Last updated 2 years ago

Was this helpful?

3️⃣