toyota-connected / ivi-homescreen

Embedded Flutter runtime targeting Embedded Linux with Wayland

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Mouse pointer motion events sometimes violate debug assertion check for state.is_down

doesnotexist opened this issue · comments

On my ubuntu 20.04, wayland+weston+ivi-homescreen running the default flutter create "increment" button app with debug engine v2.10.3 arm64, I'm finding that the app often crashes when using mouse input because this assertion check fails.

[FATAL:flutter/lib/ui/window/pointer_data_packet_converter.cc(189)] Check failed: !state.is_down. 

https://github.com/flutter/engine/blob/main/lib/ui/window/pointer_data_packet_converter.cc#L190

I believe this is a manifestation of a bug in translating wayland input events to flutter, specifically within Display::pointer_handle_motion()
https://github.com/toyota-connected/ivi-homescreen/blob/main/shell/display.cc#L399

Which calls getPointerPhase(), and in some instances the state can be such that p->buttons is not null and state == WL_POINTER_BUTTON_STATE_RELEASED which ends up translating the event to FlutterPointerPhase::kUp.
https://github.com/toyota-connected/ivi-homescreen/blob/main/shell/display.cc#L337
However, if no kDown event is sent between this kUp event and some previous kUp event (say from releasing the mouse button) then the debug assert fails and the app crashes with the FATAL warning above.

Based on what I've gathered from reading the comments in embedder.h
https://github.com/flutter/engine/blob/main/shell/platform/embedder/embedder.h#L727-L743

I propose that the wayland input event listener Display::pointer_handle_motion() should only translate to FlutterPointerPhase::kMove or FlutterPointerPhase::kHover depending on whether the left mouse button is currently pressed down or not during the motion event. PR that implements this change coming shortly.

PR merged