Skip to content

3.21.0-0.0.pre encounters asserts on Linux when showing GTK widgets only after plugin registration #144873

@Craftplacer

Description

@Craftplacer

Steps to reproduce

  1. Create new Flutter project with a plugin that interfaces with native code
  2. Move code for showing GTK widgets after fl_register_plugins
  3. Try to interface with plugin
  4. Observe the application failing to do so

Expected results

Ability to use the plugins

Actual results

Flutter complains about missing platform channels and throws assertion warnings in the standard output

Code sample

From https://pub.dev/packages/handy_window

diff --git a/linux/my_application.cc b/linux/my_application.cc
index fa74baa..3133755 100644
--- a/linux/my_application.cc
+++ b/linux/my_application.cc
@@ -48,17 +48,17 @@ static void my_application_activate(GApplication* application) {
   }
 
   gtk_window_set_default_size(window, 1280, 720);
-  gtk_widget_show(GTK_WIDGET(window));
 
   g_autoptr(FlDartProject) project = fl_dart_project_new();
   fl_dart_project_set_dart_entrypoint_arguments(project, self->dart_entrypoint_arguments);
 
   FlView* view = fl_view_new(project);
-  gtk_widget_show(GTK_WIDGET(view));
   gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(view));
 
   fl_register_plugins(FL_PLUGIN_REGISTRY(view));
 
+  gtk_widget_show(GTK_WIDGET(window));
+  gtk_widget_show(GTK_WIDGET(view));
   gtk_widget_grab_focus(GTK_WIDGET(view));
 }
import 'package:flutter/material.dart';
import 'package:url_launcher/url_launcher.dart';

void main() => runApp(const MainApp());

class MainApp extends StatelessWidget {
  const MainApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        body: Center(
          child: FilledButton(
            onPressed: () => launchUrl(Uri.https('flutter.dev')),
            child: const Text('Open site'),
          ),
        ),
      ),
    );
  }
}

Screenshots or Video

No response

Logs

Logs
** (app:3205): CRITICAL **: 11:04:29.166: FlBinaryMessenger *fl_engine_get_binary_messenger(FlEngine *): assertion 'FL_IS_ENGINE(self)' failed

** (app:3205): CRITICAL **: 11:04:29.166: FlTextureRegistrar *fl_engine_get_texture_registrar(FlEngine *): assertion 'FL_IS_ENGINE(self)' failed

** (app:3205): CRITICAL **: 11:04:29.166: FlPluginRegistrar *fl_plugin_registrar_new(FlView *, FlBinaryMessenger *, FlTextureRegistrar *): assertion 'FL_IS_BINARY_MESSENGER(messenger)' failed

(app:3205): GLib-GObject-CRITICAL **: 11:04:29.166: g_object_ref: assertion 'G_IS_OBJECT (object)' failed

** (app:3205): CRITICAL **: 11:04:29.166: FlBinaryMessenger *fl_plugin_registrar_get_messenger(FlPluginRegistrar *): assertion 'FL_IS_PLUGIN_REGISTRAR(self)' failed

** (app:3205): CRITICAL **: 11:04:29.166: FlMethodChannel *fl_method_channel_new(FlBinaryMessenger *, const gchar *, FlMethodCodec *): assertion 'FL_IS_BINARY_MESSENGER(messenger)' failed

** (app:3205): CRITICAL **: 11:04:29.166: void fl_method_channel_set_method_call_handler(FlMethodChannel *, FlMethodChannelMethodCallHandler, gpointer, GDestroyNotify): assertion 'FL_IS_METHOD_CHANNEL(self)' failed

** (app:3205): CRITICAL **: 11:04:29.166: FlBinaryMessenger *fl_engine_get_binary_messenger(FlEngine *): assertion 'FL_IS_ENGINE(self)' failed

** (app:3205): CRITICAL **: 11:04:29.166: FlTextureRegistrar *fl_engine_get_texture_registrar(FlEngine *): assertion 'FL_IS_ENGINE(self)' failed

** (app:3205): CRITICAL **: 11:04:29.166: FlPluginRegistrar *fl_plugin_registrar_new(FlView *, FlBinaryMessenger *, FlTextureRegistrar *): assertion 'FL_IS_BINARY_MESSENGER(messenger)' failed

(app:3205): GLib-GObject-CRITICAL **: 11:04:29.166: g_object_ref: assertion 'G_IS_OBJECT (object)' failed

** (app:3205): CRITICAL **: 11:04:29.166: FlBinaryMessenger *fl_plugin_registrar_get_messenger(FlPluginRegistrar *): assertion 'FL_IS_PLUGIN_REGISTRAR(self)' failed

** (app:3205): CRITICAL **: 11:04:29.166: FlMethodChannel *fl_method_channel_new(FlBinaryMessenger *, const gchar *, FlMethodCodec *): assertion 'FL_IS_BINARY_MESSENGER(messenger)' failed

** (app:3205): CRITICAL **: 11:04:29.166: void fl_method_channel_set_method_call_handler(FlMethodChannel *, FlMethodChannelMethodCallHandler, gpointer, GDestroyNotify): assertion 'FL_IS_METHOD_CHANNEL(self)' failed

** (app:3205): CRITICAL **: 11:04:29.166: FlBinaryMessenger *fl_engine_get_binary_messenger(FlEngine *): assertion 'FL_IS_ENGINE(self)' failed

** (app:3205): CRITICAL **: 11:04:29.166: FlTextureRegistrar *fl_engine_get_texture_registrar(FlEngine *): assertion 'FL_IS_ENGINE(self)' failed

** (app:3205): CRITICAL **: 11:04:29.166: FlPluginRegistrar *fl_plugin_registrar_new(FlView *, FlBinaryMessenger *, FlTextureRegistrar *): assertion 'FL_IS_BINARY_MESSENGER(messenger)' failed

** (app:3205): CRITICAL **: 11:04:29.166: FlView *fl_plugin_registrar_get_view(FlPluginRegistrar *): assertion 'FL_IS_PLUGIN_REGISTRAR(self)' failed

(app:3205): Gtk-CRITICAL **: 11:04:29.166: gtk_widget_get_toplevel: assertion 'GTK_IS_WIDGET (widget)' failed

(app:3205): Gtk-CRITICAL **: 11:04:29.166: gtk_window_get_screen: assertion 'GTK_IS_WINDOW (window)' failed

(app:3205): Gdk-CRITICAL **: 11:04:29.166: gdk_screen_is_composited: assertion 'GDK_IS_SCREEN (screen)' failed

** (app:3205): CRITICAL **: 11:04:29.166: FlBinaryMessenger *fl_engine_get_binary_messenger(FlEngine *): assertion 'FL_IS_ENGINE(self)' failed

** (app:3205): CRITICAL **: 11:04:29.166: FlTextureRegistrar *fl_engine_get_texture_registrar(FlEngine *): assertion 'FL_IS_ENGINE(self)' failed

** (app:3205): CRITICAL **: 11:04:29.166: FlPluginRegistrar *fl_plugin_registrar_new(FlView *, FlBinaryMessenger *, FlTextureRegistrar *): assertion 'FL_IS_BINARY_MESSENGER(messenger)' failed

(app:3205): GLib-GObject-CRITICAL **: 11:04:29.166: g_object_ref: assertion 'G_IS_OBJECT (object)' failed

** (app:3205): CRITICAL **: 11:04:29.166: FlBinaryMessenger *fl_plugin_registrar_get_messenger(FlPluginRegistrar *): assertion 'FL_IS_PLUGIN_REGISTRAR(self)' failed

** (app:3205): CRITICAL **: 11:04:29.166: FlMethodChannel *fl_method_channel_new(FlBinaryMessenger *, const gchar *, FlMethodCodec *): assertion 'FL_IS_BINARY_MESSENGER(messenger)' failed

** (app:3205): CRITICAL **: 11:04:29.166: void fl_method_channel_set_method_call_handler(FlMethodChannel *, FlMethodChannelMethodCallHandler, gpointer, GDestroyNotify): assertion 'FL_IS_METHOD_CHANNEL(self)' failed
Exception
[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: MissingPluginException(No implementation found for method launch on channel plugins.flutter.io/url_launcher_linux)
#0      MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:332:7)
<asynchronous suspension>
#1      UrlLauncherLinux.launchUrl (package:url_launcher_linux/url_launcher_linux.dart:47:13)
<asynchronous suspension>

Flutter Doctor output

Doctor output
[✓] Flutter (Channel master, 3.21.0-2.0.pre.63, on Artix Linux 6.7.4-artix1-1, locale en_US.UTF-8)
    • Flutter version 3.21.0-2.0.pre.63 on channel master at /home/nyanya/.local/lib/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision f733e3a441 (3 hours ago), 2024-03-09 15:50:23 +0800
    • Engine revision 196132ffe2
    • Dart version 3.4.0 (build 3.4.0-219.0.dev)
    • DevTools version 2.33.1

[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    • Android SDK at /home/nyanya/.local/lib/android-sdk
    • Platform android-34, build-tools 34.0.0
    • Java binary at: /opt/android-studio/jbr/bin/java
    • Java version OpenJDK Runtime Environment (build 17.0.7+0-17.0.7b1000.6-10550314)
    • All Android licenses accepted.

[✓] Chrome - develop for the web
    • CHROME_EXECUTABLE = /usr/bin/chromium

[✓] Linux toolchain - develop for Linux desktop
    • clang version 16.0.6
    • cmake version 3.28.3
    • ninja version 1.11.1
    • pkg-config version 2.1.0

[!] Android Studio (version unknown)
    • Android Studio at /opt/android-studio
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    ✗ Unable to determine Android Studio version.
    • Java version OpenJDK Runtime Environment (build 17.0.7+0-17.0.7b1000.6-10550314)

[✓] IntelliJ IDEA Ultimate Edition (version 2023.3)
    • IntelliJ at /home/nyanya/.local/share/JetBrains/Toolbox/apps/intellij-idea-ultimate
    • Flutter plugin version 78.1.1
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart

[✓] Connected device (2 available)
    • Linux (desktop) • linux  • linux-x64      • Artix Linux 6.7.4-artix1-1
    • Chrome (web)    • chrome • web-javascript • Chromium 122.0.6261.39 Arch Linux

[✓] Network resources
    • All expected network resources are available.

! Doctor found issues in 1 category.

Metadata

Metadata

Assignees

Labels

P2Important issues not at the top of the work lista: desktopRunning on desktopc: regressionIt was better in the past than it is nowengineflutter/engine related. See also e: labels.found in release: 3.21Found to occur in 3.21has reproducible stepsThe issue has been confirmed reproducible and is ready to work onplatform-linuxBuilding on or for Linux specificallyr: fixedIssue is closed as already fixed in a newer versionteam-linuxOwned by the Linux platform teamtriaged-linuxTriaged by the Linux platform team

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions