Skip to content

[Linux Desktop]Unhandled Exception: 'package:flutter/src/rendering/mouse_tracker.dart': Failed assertion: line 317 pos 18: 'event is! PointerRemovedEvent': is not true. #100659

Closed

Description

@cedarbob

Expected results:

I wrote a simple desktop app to exhibit flutter assertion failures in mouse_tracker.dart. These failures occur at startup of the app - not always, but on a high percentage of runs.

Actual results:
Sometimes starts with assertion failures, sometimes not.

The example uses the Google window_size plugin to constrain the app window size, then runs a trivial app consisting of a Listener widget wrapping a Container. I suspect that the problem is with the window_size plugin, since I haven't seen the issue when I comment out the lines of code using it

code sample.
import 'dart:async';
import 'dart:io';
import 'package:flutter/material.dart';

import 'package:window_size/window_size.dart';

Future<void> main() async {

  WidgetsFlutterBinding.ensureInitialized();

  if (Platform.isLinux) {
    setWindowMaxSize(const Size(640, 480));
    setWindowMinSize(const Size(640, 480));
  }

  runApp(Listener(onPointerDown: _pointerEventListener,
      child: Container()));
}

void _pointerEventListener(PointerEvent event) {

  print('Pointer down at: ${event.position}');
}
Logs
Launching test/mouse_tracker_bug_test.dart on Linux in debug mode...
Building Linux application...
Debug service listening on ws://127.0.0.1:45687/jLrRROscyPg=/ws
Syncing files to device Linux...
[ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: 'package:flutter/src/rendering/mouse_tracker.dart': Failed assertion: line 317 pos 18: 'event is! PointerRemovedEvent': is not true.
#0      _AssertionError._doThrowNew (dart:core-patch/errors_patch.dart:51:61)
#1      _AssertionError._throwNew (dart:core-patch/errors_patch.dart:40:5)
#2      MouseTracker.updateWithEvent.<anonymous closure>.<anonymous closure> (package:flutter/src/rendering/mouse_tracker.dart:317:18)
#3      MouseTracker._deviceUpdatePhase (package:flutter/src/rendering/mouse_tracker.dart:206:9)
#4      MouseTracker.updateWithEvent.<anonymous closure> (package:flutter/src/rendering/mouse_tracker.dart:312:7)
#5      MouseTracker._monitorMouseConnection (package:flutter/src/rendering/mouse_tracker.dart:190:9)
#6      MouseTracker.updateWithEvent (package:flutter/src/rendering/mouse_tracker.dart:311:5)
#7      RendererBinding.dispatchEvent (package:flutter/src/rendering/binding.dart:314:20)
#8      GestureBinding._handlePointerEventImmediately (package:flutter/src/gestures/binding.dart:374:7)
#9      GestureBinding.handlePointerEvent (package:flutter/src/gestures/binding.dart:338:5)
#10     GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:296:7)
#11     GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:279:7)
#12     _rootRunUnary (dart:async/zone.dart:1442:13)
#13     _CustomZone.runUnary (dart:async/zone.dart:1335:19)
#14     _CustomZone.runUnaryGuarded (dart:async/zone.dart:1244:7)
#15     _invoke1 (dart:ui/hooks.dart:170:10)
#16     PlatformDispatcher._dispatchPointerDataPacket (dart:ui/platform_dispatcher.dart:331:7)
#17     _dispatchPointerDataPacket (dart:ui/hooks.dart:94:31)


======== Exception caught by scheduler library =====================================================
The following assertion was thrown during a scheduler callback:
'package:flutter/src/rendering/mouse_tracker.dart': Failed assertion: line 201 pos 12: '!_debugDuringDeviceUpdate': is not true.


Either the assertion indicates an error in the framework itself, or we should provide substantially more information in this error message to help you determine and fix the underlying cause.
In either case, please report this assertion by filing a bug on GitHub:
  https://github.com/flutter/flutter/issues/new?template=2_bug.md

When the exception was thrown, this was the stack: 
#2      MouseTracker._deviceUpdatePhase (package:flutter/src/rendering/mouse_tracker.dart:201:12)
#3      MouseTracker.updateAllDevices (package:flutter/src/rendering/mouse_tracker.dart:353:5)
#4      RendererBinding._scheduleMouseTrackerUpdate.<anonymous closure> (package:flutter/src/rendering/binding.dart:380:22)
#5      SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:1144:15)
#6      SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:1089:9)
#7      SchedulerBinding._handleDrawFrame (package:flutter/src/scheduler/binding.dart:995:5)
#11     _invoke (dart:ui/hooks.dart:151:10)
#12     PlatformDispatcher._drawFrame (dart:ui/platform_dispatcher.dart:308:5)
#13     _drawFrame (dart:ui/hooks.dart:115:31)
(elided 5 frames from class _AssertionError and dart:async)
====================================================================================================
Lost connection to device.

[✓] Flutter (Channel stable, 2.10.3, on Ubuntu 20.04.4 LTS 5.4.0-104-generic, locale
    en_US.UTF-8)
    • Flutter version 2.10.3 at /home/rhr/Tools/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 7e9793dee1 (3 weeks ago), 2022-03-02 11:23:12 -0600
    • Engine revision bd539267b4
    • Dart version 2.16.1
    • DevTools version 2.9.2

[✓] Android toolchain - develop for Android devices (Android SDK version 32.0.0)
    • Android SDK at /home/rhr/Android/Sdk
    • Platform android-32, build-tools 32.0.0
    • Java binary at: /usr/lib/jvm/java-11-openjdk-amd64/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.14+9-Ubuntu-0ubuntu2.20.04)
    • All Android licenses accepted.

[✓] Chrome - develop for the web
    • Chrome at google-chrome

[✓] Linux toolchain - develop for Linux desktop
    • clang version 9.0.1-12
    • cmake version 3.16.3
    • ninja version 1.10.0
    • pkg-config version 0.29.1

[!] Android Studio (not installed)
    • Android Studio not found; download from https://developer.android.com/studio/index.html
      (or visit https://flutter.dev/docs/get-started/install/linux#android-setup for detailed
      instructions).

[✓] IntelliJ IDEA Community Edition (version 2021.2)
    • IntelliJ at /home/rhr/Tools/idea-IC-212.4416.7
    • Flutter plugin version 63.3.3
    • Dart plugin version 212.5632

[✓] Connected device (2 available)
    • Linux (desktop) • linux  • linux-x64      • Ubuntu 20.04.4 LTS 5.4.0-104-generic
    • Chrome (web)    • chrome • web-javascript • Google Chrome 99.0.4844.74

[✓] HTTP Host Availability
    • All required HTTP hosts are available

! Doctor found issues in 1 category.

Activity

  1. maheshj01 commented on Mar 24, 2022

    @maheshj01
    Member

    Hi @cedarbob, thanks for filing the issue I was able to reproduce the issue. on the latest stable and the master channel. It looks like this happens if the pointer loses the focus from the window immediately on launch

    Reproducible steps

    • add dependency to pubspec.yaml
      window_size:
        git:
          url: https://github.com/google/flutter-desktop-embedding.git
          path: plugins/window_size
    
    • run the above code sample

    This issue doesn't seem related to the window_size plugin, To reproduce the issue the cursor must be positioned such that when the app loads the cursor focuses the window and when the window resizes as per the code sample the cursor should loose the focus.

    The below video shows the above mentioned reproducible steps

    Screencast.from.24-03-22.05.19.39.PM.IST.mp4

    The logs look similar to this issue for mac #80867

    logs
    Launching lib/main.dart on Linux in debug mode...
    Connecting to VM Service at ws://127.0.0.1:35891/v2zr0YehP-s=/ws
    [ERROR:flutter/lib/ui/ui_dart_state.cc(198)] Unhandled Exception: 'package:flutter/src/rendering/mouse_tracker.dart': Failed assertion: line 322 pos 18: 'event is! PointerRemovedEvent': is not true.
    #0      _AssertionError._doThrowNew (dart:core-patch/errors_patch.dart:51:61)
    #1      _AssertionError._throwNew (dart:core-patch/errors_patch.dart:40:5)
    #2      MouseTracker.updateWithEvent.<anonymous closure>.<anonymous closure>
    #3      MouseTracker._deviceUpdatePhase
    #4      MouseTracker.updateWithEvent.<anonymous closure>
    #5      MouseTracker._monitorMouseConnection
    #6      MouseTracker.updateWithEvent
    #7      RendererBinding.dispatchEvent
    #8      GestureBinding._handlePointerEventImmediately
    #9      GestureBinding.handlePointerEvent
    #10     GestureBinding._flushPointerEventQueue
    #11     GestureBinding._handlePointerDataPacket
    #12     _rootRunUnary (dart:async/zone.dart:1442:13)
    #13     _CustomZone.runUnary (dart:async/zone.dart:1335:19)
    #14     _CustomZone.runUnaryGuarded (dart:async/zone.dart:1244:7)
    #15     _invoke1 (dart:ui/hooks.dart:170:10)
    #16     PlatformDispatcher._dispatchPointerDataPacket (dart:ui/platform_dispatcher.dart:331:7)
    #17     _dispatchPointerDataPacket (dart:ui/hooks.dart:94:31)
    
    ════════ Exception caught by scheduler library ═════════════════════════════════
    The following assertion was thrown during a scheduler callback:
    'package:flutter/src/rendering/mouse_tracker.dart': Failed assertion: line 206 pos 12: '!_debugDuringDeviceUpdate': is not true.
    
    Either the assertion indicates an error in the framework itself, or we should provide substantially more information in this error message to help you determine and fix the underlying cause.
    In either case, please report this assertion by filing a bug on GitHub:
      https://github.com/flutter/flutter/issues/new?template=2_bug.md
    
    When the exception was thrown, this was the stack
    #2      MouseTracker._deviceUpdatePhase
    #3      MouseTracker.updateAllDevices
    #4      RendererBinding._scheduleMouseTrackerUpdate.<anonymous closure>
    #5      SchedulerBinding._invokeFrameCallback
    #6      SchedulerBinding.handleDrawFrame
    #7      SchedulerBinding._handleDrawFrame
    #11     _invoke (dart:ui/hooks.dart:151:10)
    #12     PlatformDispatcher._drawFrame (dart:ui/platform_dispatcher.dart:308:5)
    #13     _drawFrame (dart:ui/hooks.dart:115:31)
    (elided 5 frames from class _AssertionError and dart:async)
    ════════════════════════════════════════════════════════════════════════════════
    
    flutter doctor -v (Linux)
    [✓] Flutter (Channel stable, 2.10.3, on Ubuntu 20.04.4 LTS 5.13.0-30-generic, locale en_GB.UTF-8)
        • Flutter version 2.10.3 at /home/mahesh/Development/stable
        • Upstream repository https://github.com/flutter/flutter.git
        • Framework revision 7e9793dee1 (13 days ago), 2022-03-02 11:23:12 -0600
        • Engine revision bd539267b4
        • Dart version 2.16.1
        • DevTools version 2.9.2
    
    [✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
        • Android SDK at /home/mahesh/Android/Sdk
        • Platform android-31, build-tools 31.0.0
        • Java binary at: /home/mahesh/Downloads/android-studio-2020.3.1.25-linux/android-studio/jre/bin/java
        • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)
        • All Android licenses accepted.
    
    [✓] Chrome - develop for the web
        • Chrome at google-chrome
    
    [✓] Linux toolchain - develop for Linux desktop
        • clang version 10.0.0-4ubuntu1
        • cmake version 3.16.3
        • ninja version 1.10.0
        • pkg-config version 0.29.1
    
    [✓] Android Studio (version 2020.3)
        • Android Studio at /home/mahesh/Downloads/android-studio-2020.3.1.25-linux/android-studio
        • Flutter plugin version 63.2.1
        • Dart plugin version 203.8452
        • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)
    
    [✓] VS Code (version 1.64.2)
        • VS Code at /usr/share/code
        • Flutter extension version 3.36.0
    
    [✓] Connected device (2 available)
        • Linux (desktop) • linux  • linux-x64      • Ubuntu 20.04.4 LTS 5.13.0-30-generic
        • Chrome (web)    • chrome • web-javascript • Google Chrome 98.0.4758.102
    
    [✓] HTTP Host Availability
        • All required HTTP hosts are available
    
    • No issues found!
    
    [✓] Flutter (Channel master, 2.13.0-0.0.pre.218, on Ubuntu 20.04.4 LTS
        5.13.0-30-generic, locale en_IN)
        • Flutter version 2.13.0-0.0.pre.218 at /home/mahesh/Development/master
        • Upstream repository https://github.com/flutter/flutter.git
        • Framework revision 654ccf35c6 (19 minutes ago), 2022-03-22 23:23:08 -0700
        • Engine revision 4fbff7a511
        • Dart version 2.17.0 (build 2.17.0-227.0.dev)
        • DevTools version 2.11.4
    
    [✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
        • Android SDK at /home/mahesh/Android/Sdk
        • Platform android-31, build-tools 31.0.0
        • Java binary at:
          /home/mahesh/Downloads/android-studio-2020.3.1.25-linux/android-studio/jre
          /bin/java
        • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)
        • All Android licenses accepted.
    
    [✓] Chrome - develop for the web
        • Chrome at google-chrome
    
    [✓] Linux toolchain - develop for Linux desktop
        • clang version 10.0.0-4ubuntu1
        • cmake version 3.16.3
        • ninja version 1.10.0
        • pkg-config version 0.29.1
    
    [✓] Android Studio (version 2020.3)
        • Android Studio at
          /home/mahesh/Downloads/android-studio-2020.3.1.25-linux/android-studio
        • Flutter plugin version 63.2.1
        • Dart plugin version 203.8452
        • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)
    
    [✓] VS Code (version 1.64.2)
        • VS Code at /usr/share/code
        • Flutter extension can be installed from:
          🔨 https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter
    
    [✓] Connected device (2 available)
        • Linux (desktop) • linux  • linux-x64      • Ubuntu 20.04.4 LTS
          5.13.0-30-generic
        • Chrome (web)    • chrome • web-javascript • Google Chrome 98.0.4758.102
    
    [✓] HTTP Host Availability
        • All required HTTP hosts are available
    
    • No issues found!
    
  2. added
    platform-linuxBuilding on or for Linux specifically
    a: error messageError messages from the Flutter framework
    a: mouseIssues related to using a mouse or mouse support
    has reproducible stepsThe issue has been confirmed reproducible and is ready to work on
    and removed
    in triagePresently being triaged by the triage team
    on Mar 24, 2022
  3. changed the title [-]Multiple Assertion Faillures in mouse_tracker.dart[/-] [+][Linux Desktop]Unhandled Exception: 'package:flutter/src/rendering/mouse_tracker.dart': Failed assertion: line 317 pos 18: 'event is! PointerRemovedEvent': is not true.[/+] on Mar 24, 2022
  4. added
    P2Important issues not at the top of the work list
    on Mar 24, 2022
  5. ThraaxSession commented on May 1, 2022

    @ThraaxSession

    Is there something new about this issue? I bothers me too. :(

  6. jason-simmons commented on May 4, 2022

    @jason-simmons
    Member

    I was seeing the event is! PointerRemovedEvent assertion failure after launching Flutter apps on a Linux desktop.

    Traced through this and noticed a race between startup of the Linux embedder and the Flutter framework. When the FlView sends the first pointer add event to the engine, the framework binding may not yet have installed the onPointerDataPacket callback.

    If the add event does not reach the framework, then the first event seen by the framework is the remove event, which triggers the assertion.

    It may make sense for these events to be buffered until the framework provides its pointer data handlers (see https://github.com/flutter/engine/blob/main/lib/ui/channel_buffers.dart)

  7. github-actions commented on May 18, 2022

    @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.

  8. locked as resolved and limited conversation to collaborators on May 18, 2022
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

    P2Important issues not at the top of the work lista: desktopRunning on desktopa: error messageError messages from the Flutter frameworka: mouseIssues related to using a mouse or mouse supportfound in release: 2.10Found to occur in 2.10found in release: 2.13Found to occur in 2.13has reproducible stepsThe issue has been confirmed reproducible and is ready to work onplatform-linuxBuilding on or for Linux specifically

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions