Skip to content

[Linux] fl_view_dispose should clear the FlTextInputHandler::widget #188657

Description

@loic-sharma

The text input handler has a pointer to the currently focused widget in FlTextInputHandler::widget:

// The widget with input focus.
GtkWidget* widget;

That raw pointer is updated when focus moves to another view:

// Implements GtkWidget::key_press_event.
static gboolean fl_view_focus_in_event(GtkWidget* widget,
GdkEventFocus* event) {
FlView* self = FL_VIEW(widget);
fl_text_input_handler_set_widget(
fl_engine_get_text_input_handler(self->engine), widget);
return FALSE;
}

If that view's window is closed, its corresponding FlView is disposed and finalized, while the FlEngine and its FlTextInputHandler persist. Because the view's fl_view_dispose does not notify or clear the handler's dangling widget pointer, and because there is no focus_out_event override to clear it on focus loss, the raw pointer can point to freed memory:

static void fl_view_dispose(GObject* object) {
FlView* self = FL_VIEW(object);
g_cancellable_cancel(self->cancellable);
g_clear_object(&self->zoom_gesture);
g_clear_object(&self->rotate_gesture);
if (self->engine != nullptr) {
// Release the view ID from the engine.
fl_engine_remove_view(self->engine, self->view_id, nullptr, nullptr,
nullptr);
}
g_clear_object(&self->engine);
g_clear_object(&self->window_state_monitor);
g_clear_object(&self->scrolling_manager);
g_clear_object(&self->pointer_manager);
g_clear_object(&self->touch_manager);
g_clear_object(&self->view_accessible);
g_clear_object(&self->cancellable);
G_OBJECT_CLASS(fl_view_parent_class)->dispose(object);
}

Internal bug link: b/525523757

Activity

  1. added
    a: text inputEntering text in a text field or keyboard related problems
    c: crashStack traces logged to the console
    platform-linuxBuilding on or for Linux specifically
    team-linuxOwned by the Linux platform team
    a: multi windowIssues related to multi window support
    c: fatal crashCrashes that terminate the process
    and removed
    c: crashStack traces logged to the console
    on Jun 26, 2026
  2. github-actions commented on Jul 14, 2026

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

  3. locked as resolved and limited conversation to collaborators on Jul 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    a: multi windowIssues related to multi window supporta: text inputEntering text in a text field or keyboard related problemsc: fatal crashCrashes that terminate the processplatform-linuxBuilding on or for Linux specificallyteam-linuxOwned 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