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

Bug(android): Failed to create snapshot: snapshotting timed out. #794

Open
thuan-savvycom opened this issue Dec 2, 2024 · 2 comments
Open

Comments

@thuan-savvycom
Copy link

thuan-savvycom commented Dec 2, 2024

MapBox version: 2.4.1
Sometimes I got a timed out exception:

Non-fatal Exception: io.flutter.plugins.firebase.crashlytics.FlutterError: PlatformException(2342345, Failed to create snapshot: snapshotting timed out., null, null)

I see in the android code, current timeout is 1 second. Can we increate the timeout?

@RenderThread
fun snapshot(): Bitmap? {
  if (!readyForSnapshot.get()) {
    logE(TAG, "Could not take map snapshot because map is not ready yet.")
    return null
  }
  val lock = ReentrantLock()
  val waitCondition = lock.newCondition()
  val legacyMode = snapshotLegacyModeEnabled
  lock.withLock {
    var snapshot: Bitmap? = null
    renderThread.queueRenderEvent(
      RenderEvent(
        runnable = {
          lock.withLock {
            snapshot = performSnapshot(legacyMode)
            waitCondition.signal()
          }
        },
        needRender = true,
      )
    )
    waitCondition.await(1, TimeUnit.SECONDS)
    return snapshot
  }
}
@evil159
Copy link
Contributor

evil159 commented Dec 2, 2024

Hi @thuan-savvycom, the timeout is defined statically on the Android side, not sure why it times out as snapshot should be ready in much less than 1 second, this could happen if the rendering queue is clogged, which is probably something that older devices more susceptible of. Could you give Snapshotter a go? It doesn't have any timeouts and it uses GPU rendering, so snapshots are usually delivered very quickly.

@thuan-savvycom
Copy link
Author

This issue occurs on flagship phones such as the Galaxy Z Fold6, Galaxy S21 5G, Moto G53 5G, and OnePlus 9 Pro 5G...
I am using MapBox in my running application to draw the running route on the map. I use PolylineAnnotationManager to draw the route with thousands of coordinates. I tried using Snapshotter, but I couldn't capture the map including the polyline route.

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