谷歌地图dequeueBuffer:BufferQueue已被放弃

2024-01-12

我在使用 Google 地图小部件时遇到了一些问题。
简而言之,我有 3 个页面,带有底部导航栏的主页、地图页面 - 脚手架主体中带有 GoogleMap 的基本状态小部件,以及另一个页面。每次我从地图页面切换得太快时,我都会收到此错误,并且整个应用程序都会冻结。

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

据我了解,这可以归结为地图在 SurfaceTexture 销毁后继续加载的事实,如下所示:https://stackoverflow.com/a/22490648/11318016 https://stackoverflow.com/a/22490648/11318016
我看到在android上有解决这个问题的方法,但是我没有找到在flutter中处理它的方法。


我遇到了同样的问题,我修复了它,在我的 statefulwidget 中添加了“with AutomaticKeepAliveClientMixin”。它将使您的小部件永不消亡,并使您免于出现过多帧的异常。这:E/BufferQueueProducer( 9243): [SurfaceTexture-0-9243-14] dequeueBuffer: BufferQueue has been abandoned仍将在调试终端中,但这不是错误。

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)),
          )
        ],
      ),
    );
  }
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

谷歌地图dequeueBuffer:BufferQueue已被放弃 的相关文章

随机推荐