Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google maps dequeueBuffer: BufferQueue has been abandoned

Tags:

flutter

dart

I'm having a little bit of trouble with Google Map widget.
In short, I have 3 pages, home page with bottom navigation bar, map page - basic stateful widget with GoogleMap in Scaffold body, and another page. Everytime I switch from map page too fast I'm getting this error and whole app freezes.

E/BufferQueueProducer( 9243): [SurfaceTexture-0-9243-14] dequeueBuffer: BufferQueue has been abandoned

To my understanding it boils down to the fact that map keep loading after SurfaceTexture destruction, like here: https://stackoverflow.com/a/22490648/11318016
I see there are ways to solve it on android, but I didn't find a way to handle it in flutter.

like image 280
HPressure Avatar asked Jun 17 '19 13:06

HPressure


1 Answers

I had the same problem and I fixed it adding "with AutomaticKeepAliveClientMixin" to my statefulwidget. It'll make your widget never die and save you from the exception about present too much frames. This: E/BufferQueueProducer( 9243): [SurfaceTexture-0-9243-14] dequeueBuffer: BufferQueue has been abandoned will be still in debug terminal but it's not an error.

import 'package:flutter/material.dart';
import 'package:google_maps_flutter/google_maps_flutter.dart';

class GoThereView extends StatefulWidget {
  @override
  _GoThereViewState createState() => _GoThereViewState();
}

class _GoThereViewState extends State<GoThereView> with AutomaticKeepAliveClientMixin {
  GoogleMapController _controller;

  @override
  bool get wantKeepAlive => true;

  void _onMapCreated(GoogleMapController controller) {
    if( _controller == null )
      _controller = controller;
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(),
      body: Stack(
        children: <Widget>[
          GoogleMap(
            onMapCreated: _onMapCreated,
            initialCameraPosition: CameraPosition(target: LatLng(26.8206, 30.8025)),
          )
        ],
      ),
    );
  }
}
like image 141
José Luna Avatar answered Oct 20 '22 22:10

José Luna