Skip to content

Thread assertion failure in SnapshotDisplayList with AndroidPlatformView #113437

@stuartmorgan-g

Description

@stuartmorgan-g

While trying to debug a regression in Android Platform Views using a debug engine, I hit the following assertion failure that looks like it's in the new code from flutter/engine#35283. I don't think it's related to the regression, and I can probably hack around it for now to unblock my debugging work, but it looks like we have a pointer threading violation here.

The stack is:

signal 6 (SIGABRT), code -1 (SI_QUEUE), fault addr --------
Abort message: '[FATAL:flutter/fml/memory/weak_ptr.h(111)] Check failed: (checker_.checker).IsCreationThreadCurrent(). '
    x0  0000000000000000  x1  0000000000005ec3  x2  0000000000000006  x3  0000007fe45179d0
    x4  6f5e6a6064762e78  x5  6f5e6a6064762e78  x6  6f5e6a6064762e78  x7  7f7f7f7f7f7f7f7f
    x8  00000000000000f0  x9  0000007ea8720a00  x10 0000000000000001  x11 0000007ea875ece4
    x12 0000000000003b6d  x13 0000000000000069  x14 0000007fe45168a0  x15 000000001a117914
    x16 0000007ea87c3d60  x17 0000007ea87a0b70  x18 0000007eb7f38000  x19 0000000000005ec3
    x20 0000000000005ec3  x21 00000000ffffffff  x22 00000000ffffffff  x23 b400007cb33794d0
    x24 b400007cb33795a0  x25 b400007cb33794e8  x26 b400007cb337ef08  x27 0000000000000000
    x28 00000000ffffffff  x29 0000007fe4517a50
    lr  0000007ea8750868  sp  0000007fe45179b0  pc  0000007ea8750894  pst 0000000000000000
backtrace:
      #00 pc 0000000000051894  /apex/com.android.runtime/lib64/bionic/libc.so (abort+164) (BuildId: 058e3ec96fa600fb840a6a6956c6b64e)
      #01 pc 0000000001e26c28  [...]/lib/arm64/libflutter.so (std::_LIBCPP_ABI_NAMESPACE::__throw_bad_optional_access[abi:v15000]()+8) (BuildId: e885b5977fbe7860a649eef42968283c5dd76e88)
      #02 pc 0000000001eecc10  [...]/lib/arm64/libflutter.so (fml::LogMessage::~LogMessage()+260) (BuildId: e885b5977fbe7860a649eef42968283c5dd76e88)
      #03 pc 0000000001e30a4c  [...]/lib/arm64/libflutter.so (fml::WeakPtr<flutter::PlatformViewAndroid>::CheckThreadSafety() const+156) (BuildId: e885b5977fbe7860a649eef42968283c5dd76e88)
      #04 pc 0000000001e2efc4  [...]/lib/arm64/libflutter.so (fml::WeakPtr<flutter::PlatformViewAndroid>::operator bool() const+32) (BuildId: e885b5977fbe7860a649eef42968283c5dd76e88)
      #05 pc 0000000002f0d3e4  [...]/lib/arm64/libflutter.so (flutter::DlDeferredImageGPUSkia::ImageWrapper::SnapshotDisplayList(std::_LIBCPP_ABI_NAMESPACE::shared_ptr<flutter::LayerTree>)::$_1::operator()() const+96) (BuildId: e885b5977fbe7860a649eef42968283c5dd76e88)
      #06 pc 0000000002f0d374  [...]/lib/arm64/libflutter.so (decltype(std::declval<flutter::DlDeferredImageGPUSkia::ImageWrapper::SnapshotDisplayList(std::_LIBCPP_ABI_NAMESPACE::shared_ptr<flutter::LayerTree>)::$_1&>()()) std::_LIBCPP_ABI_NAMESPACE::__invoke[abi:v15000]<flutter::DlDeferredImageGPUSkia::ImageWrapper::SnapshotDisplayList(std::_LIBCPP_ABI_NAMESPACE::shared_ptr<flutter::LayerTree>)::$_1&>(flutter::DlDeferredImageGPUSkia::ImageWrapper::SnapshotDisplayList(std::_LIBCPP_ABI_NAMESPACE::shared_ptr<flutter::LayerTree>)::$_1&)+20) (BuildId: e885b5977fbe7860a649eef42968283c5dd76e88)
      #07 pc 0000000002f0d350  [...]/lib/arm64/libflutter.so (void std::_LIBCPP_ABI_NAMESPACE::__invoke_void_return_wrapper<void, true>::__call<flutter::DlDeferredImageGPUSkia::ImageWrapper::SnapshotDisplayList(std::_LIBCPP_ABI_NAMESPACE::shared_ptr<flutter::LayerTree>)::$_1&>(flutter::DlDeferredImageGPUSkia::ImageWrapper::SnapshotDisplayList(std::_LIBCPP_ABI_NAMESPACE::shared_ptr<flutter::LayerTree>)::$_1&)+20) (BuildId: e885b5977fbe7860a649eef42968283c5dd76e88)
      #08 pc 0000000002f0d32c  [...]/lib/arm64/libflutter.so (std::_LIBCPP_ABI_NAMESPACE::__function::__alloc_func<flutter::DlDeferredImageGPUSkia::ImageWrapper::SnapshotDisplayList(std::_LIBCPP_ABI_NAMESPACE::shared_ptr<flutter::LayerTree>)::$_1, std::_LIBCPP_ABI_NAMESPACE::allocator<flutter::DlDeferredImageGPUSkia::ImageWrapper::SnapshotDisplayList(std::_LIBCPP_ABI_NAMESPACE::shared_ptr<flutter::LayerTree>)::$_1>, void ()>::operator()[abi:v15000]()+24) (BuildId: e885b5977fbe7860a649eef42968283c5dd76e88)
      #09 pc 0000000002f0d044  [...]/lib/arm64/libflutter.so (std::_LIBCPP_ABI_NAMESPACE::__function::__func<flutter::DlDeferredImageGPUSkia::ImageWrapper::SnapshotDisplayList(std::_LIBCPP_ABI_NAMESPACE::shared_ptr<flutter::LayerTree>)::$_1, std::_LIBCPP_ABI_NAMESPACE::allocator<flutter::DlDeferredImageGPUSkia::ImageWrapper::SnapshotDisplayList(std::_LIBCPP_ABI_NAMESPACE::shared_ptr<flutter::LayerTree>)::$_1>, void ()>::operator()()+24) (BuildId: e885b5977fbe7860a649eef42968283c5dd76e88)
      #10 pc 0000000001ee6218  [...]/lib/arm64/libflutter.so (std::_LIBCPP_ABI_NAMESPACE::__function::__value_func<void ()>::operator()[abi:v15000]() const+64) (BuildId: e885b5977fbe7860a649eef42968283c5dd76e88)
      #11 pc 0000000001ee5058  [...]/lib/arm64/libflutter.so (std::_LIBCPP_ABI_NAMESPACE::function<void ()>::operator()() const+20) (BuildId: e885b5977fbe7860a649eef42968283c5dd76e88)
      #12 pc 0000000001eef6cc  [...]/lib/arm64/libflutter.so (fml::MessageLoopImpl::FlushTasks(fml::FlushType)+160) (BuildId: e885b5977fbe7860a649eef42968283c5dd76e88)
      #13 pc 0000000001eef5d8  [...]/lib/arm64/libflutter.so (fml::MessageLoopImpl::RunExpiredTasksNow()+24) (BuildId: e885b5977fbe7860a649eef42968283c5dd76e88)
[...]

STR

Repro setup step
  • flutter create some_app
  • Add the following dependency in pubspec.yaml:
    google_maps_flutter: ^2.2.1
    
  • Add a Maps API key to AndroidManifest.xml (example). It looks like putting a bogus key there gets things far enough to repro the issue, but if not let me know.
  • Replace main.lib with the following:
import 'package:google_maps_flutter/google_maps_flutter.dart';
import 'package:flutter/material.dart';

void main() => runApp(const MaterialApp(home: MyApp()));

class MyApp extends StatefulWidget {
  const MyApp({super.key});

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: const Text('Outer Map')),
      body: Stack(
        children: [
          const GoogleMap(
            initialCameraPosition: CameraPosition(
              target: LatLng(0, 0),
              zoom: 2,
            ),
          ),
          FloatingActionButton(
            onPressed: () {
              Navigator.of(context).push(
                MaterialPageRoute(
                  builder: (context) => const SimpleMap(),
                ),
              );
            },
          ),
        ],
      ),
    );
  }
}

class SimpleMap extends StatefulWidget {
  const SimpleMap({super.key});

  @override
  State<SimpleMap> createState() => _SimpleMap();
}

class _SimpleMap extends State<SimpleMap> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: const Text('Inner Map')),
      body: Stack(
        children: [
          const ExcludeSemantics(
            child: GoogleMap(
              initialCameraPosition: CameraPosition(
                target: LatLng(0, 0),
                zoom: 2,
              ),
            ),
          ),
          FloatingActionButton(
            onPressed: () {
              Navigator.of(context).push(
                MaterialPageRoute(
                  builder: (context) => Scaffold(
                    appBar: AppBar(
                      title: const Text('next page'),
                    ),
                    body: const Text('test'),
                  ),
                ),
              );
            },
          ),
        ],
      ),
    );
  }
}

To repro:

  • Launch on Android with a debug engine
  • Tap the FAB in the upper left
  • Tap the FAB in the upper left of the new screen

At this point it will explode.

Metadata

Metadata

Assignees

Labels

P1High-priority issues at the top of the work listc: crashStack traces logged to the consoleengineflutter/engine related. See also e: labels.platform-androidAndroid applications specifically

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions