bitsdojo / bitsdojo_window

A Flutter package that makes it easy to customize and work with your Flutter desktop app window.
http://www.youtube.com/watch?v=bee2AHQpGK4
MIT License
815 stars 229 forks source link

Lag for window button operations (close, maximize, minimize) #187

Open mathaou opened 2 years ago

mathaou commented 2 years ago

Flutter 3.1.0-0.0.pre.1887 (upgraded from 3.0.1 to see if latest master could help)

With a setup like this

final _windowButtons = [
  MinimizeWindowButton(
    animate: false,
    colors: WindowButtonColors(iconNormal: Colors.black),
  ),
  MaximizeWindowButton(
    animate: false,
    colors: WindowButtonColors(iconNormal: Colors.black),
  ),
  CloseWindowButton(
    animate: false,
    colors: WindowButtonColors(
        iconNormal: Colors.black,
        iconMouseDown: Colors.white,
        iconMouseOver: Colors.white,
        mouseDown: Colors.red,
        mouseOver: Colors.red),
  )
];

Using any of these operations (or calling the same functions from the window_manager plugin) has a pretty jarring delay before the operation completes. On the run-of-the-mill native app all of those are practically instantaneous, but profiling the code shows me that I'm spending close to 70ms getting a GestureDetector to service an action, and then pass that through some kind of ffi that needs bytestreams or some other binary blob to function. My gut feeling is that there isn't much that can be done to speed this up, but I thought I'd make an issue in case this is thoroughly a "me" problem and I'm just doing something wrong.

ngugcx commented 2 years ago

I experienced a similar problem today, not sure if it's related. I put WindowButtons under a MoveWindow (which enables onDoubleTap) in a Stack. In Flutter, if onDoubleTap is enabled, onTap is delayed for some time (300ms?) to detect double tap. https://github.com/flutter/flutter/issues/110300

Stack(children: [
  Row(
    children: [
      Expanded(
          child: Tabbar()),
      const WindowButtons()
    ],
  ),
  MoveWindow(),
])
Auties00 commented 2 years ago

MoveWind

Noticed the same exact thing

bitsdojo commented 2 years ago

Thank you all for reporting. Will investigate.

bitsdojo commented 2 years ago

What OS are you using for testing?

mathaou commented 2 years ago

What OS are you using for testing?

I used Windows.

nickcuypers commented 2 years ago

yeah I experienced the same today, also on Windows OS btw double tapping the app bar is "instant" and tapping the buttons is with a slight delay, I will try and take the buttons out of the moveWindow widget for now

Auties00 commented 2 years ago

yeah I experienced the same today, also on Windows OS btw double tapping the app bar is "instant" and tapping the buttons is with a slight delay, I will try and take the buttons out of the moveWindow widget for now

Just use the stack as previously explained by @ngugcx

nickcuypers commented 2 years ago

yeah I experienced the same today, also on Windows OS btw double tapping the app bar is "instant" and tapping the buttons is with a slight delay, I will try and take the buttons out of the moveWindow widget for now

Just use the stack as previously explained by @ngugcx

yes was exactly what I did 👍

nickcuypers commented 2 years ago

is there any news or estimation on this issue? workaround aint perfect for my needs sadly

asad-albadi commented 2 years ago

I have the same issue, developed multiple apps and experienced it in all of them, any chance we're getting a fix anytime soon ?

actions: MoveWindow( child: Row( children: [ const Spacer(), MinimizeWindowButton( colors: buttonColors, ), MaximizeWindowButton( colors: buttonColors, ), CloseWindowButton( colors: buttonColorsExit, ) ], ), ),

shadowmelds commented 1 year ago

A simple solution is to put the three window buttons in the container, set the container color to transparent, and the colored container will intercept the onDoubleTap() of MoveWindow() below

meltamagodan commented 3 months ago

the issue is something related to MoveWindow() widget. when i added the MoveWindow() on top of the window buttons using Stack() it made them slow.