Lag when draw fast with pen or mouse. #76699

Closed
opened 2020-05-12 20:16:53 +02:00 by Adam Stankiewicz · 41 comments

System Information
Operating system: MacOS 10.15.4
Graphics card: Intel Iris Graphics 6100 1536 MB graphics

Blender Version
Broken: 2.82a

Short description of error

When drawing something very fast in Blender, it seems that blender draws by adding lines between consecutive position. This results in very "spiky" drawing, especially when circular figures, like head, bowl and similar. Error is present in texture drawing mode, as well as grease pencil. None of the available configuration option in Blender fixes this.

Most other drawing applications add multiple points for each cursor change if motion is fast enough, by computing velocity of cursor at last point and adding enough lines between points so drawing looks smooth enough.

Exact steps for others to reproduce the error

I've attached screencast that shows this issue

Screen Recording 2020-05-12 at 20.02.10.mov

**System Information** Operating system: MacOS 10.15.4 Graphics card: Intel Iris Graphics 6100 1536 MB graphics **Blender Version** Broken: 2.82a **Short description of error** When drawing something very fast in Blender, it seems that blender draws by adding lines between consecutive position. This results in very "spiky" drawing, especially when circular figures, like head, bowl and similar. Error is present in texture drawing mode, as well as grease pencil. None of the available configuration option in Blender fixes this. Most other drawing applications add multiple points for each cursor change if motion is fast enough, by computing velocity of cursor at last point and adding enough lines between points so drawing looks smooth enough. **Exact steps for others to reproduce the error** I've attached screencast that shows this issue [Screen Recording 2020-05-12 at 20.02.10.mov](https://archive.blender.org/developer/F8531226/Screen_Recording_2020-05-12_at_20.02.10.mov)

Added subscriber: @sheerun

Added subscriber: @sheerun

#81211 was marked as duplicate of this issue

#81211 was marked as duplicate of this issue

Added subscriber: @antoniov

Added subscriber: @antoniov

Changed status from 'Needs Triage' to: 'Needs User Info'

Changed status from 'Needs Triage' to: 'Needs User Info'

Can you try 2.83 version?

Can you try 2.83 version?

2.83 not only has the same issue but also the cursor on screen lags behind what's I'm drawing on tablet by a 1-2 seconds. it's really terrible, sorry :)

2.83 not only has the same issue but also the cursor on screen lags behind what's I'm drawing on tablet by a 1-2 seconds. it's really terrible, sorry :)

I cannot reproduce on my Windows machine. It looks a problem with you mouse/tab driver or any issue related to drivers. I will ask if someone with a Mac can reproduce it.

I cannot reproduce on my Windows machine. It looks a problem with you mouse/tab driver or any issue related to drivers. I will ask if someone with a Mac can reproduce it.
Antonio Vazquez changed title from Drawing doesn't take into account velocity of cursor to GPencil: Lag when draw fast with pen. 2020-05-13 10:49:54 +02:00
Contributor

Added subscriber: @dupoxy

Added subscriber: @dupoxy
Contributor

I can reproduce the painting mode part (mouse and tab.)
file:T76699_v000.blend
video:2020-05-13 12-00-49.mp4

for grease pencil it's more like #76550

System Information
Operating system: Darwin-17.7.0-x86_64-i386-64bit 64 Bits ( MacOS 10.13.6 )

I can reproduce the painting mode part (mouse and tab.) file:[T76699_v000.blend](https://archive.blender.org/developer/F8532629/T76699_v000.blend) video:[2020-05-13 12-00-49.mp4](https://archive.blender.org/developer/F8532626/2020-05-13_12-00-49.mp4) for grease pencil it's more like #76550 **System Information** Operating system: Darwin-17.7.0-x86_64-i386-64bit 64 Bits ( MacOS 10.13.6 )

This looks a more general problem with the Tab/Pen that a problem with Grease Pencil itself.

This looks a more general problem with the Tab/Pen that a problem with Grease Pencil itself.
Antonio Vazquez changed title from GPencil: Lag when draw fast with pen. to Lag when draw fast with pen. 2020-05-21 15:37:41 +02:00
Contributor

Changed status from 'Needs User Info' to: 'Needs Developer To Reproduce'

Changed status from 'Needs User Info' to: 'Needs Developer To Reproduce'
Contributor

As I said

In #76699#930597, @dupoxy wrote:
I can reproduce the painting mode part (mouse and tab.)

no need for a Tab/Pen I can reproduce with a mouse.

As I said > In #76699#930597, @dupoxy wrote: > I can reproduce the painting mode part (mouse and tab.) no need for a Tab/Pen I can reproduce with a mouse.
Antonio Vazquez changed title from Lag when draw fast with pen. to Lag when draw fast with pen or mouse. 2020-05-21 20:15:28 +02:00

Added subscriber: @girafic

Added subscriber: @girafic

For me it is also lagging if I set the width/height to 4096px (see video attached)

Bildschirmvideo aufnehmen 2020-05-25 um 23.19.43.mp4

For me it is also lagging if I set the width/height to 4096px (see video attached) [Bildschirmvideo aufnehmen 2020-05-25 um 23.19.43.mp4](https://archive.blender.org/developer/F8554062/Bildschirmvideo_aufnehmen_2020-05-25_um_23.19.43.mp4)

Added subscriber: @PrototypeNM1

Added subscriber: @PrototypeNM1

This looks like mouse/tablet events are being coalesced and the coalesced history ignored. This becomes more apparent as the system is more taxed (working on a higher resolution image).

This looks like mouse/tablet events are being coalesced and the coalesced history ignored. This becomes more apparent as the system is more taxed (working on a higher resolution image).

Added subscriber: @jenkm

Added subscriber: @jenkm

The same behavior on Windows 7 with 2.79b, and 2.91.0 on macOS, using a mouse or Mac trackpad does not matter.

What matters is the size of the image and zoom level.

4K image:

#76699-1.png

The same image is just zoomed in:

#76699-2.png

The same behavior on **Windows 7** with **2.79b**, and **2.91.0** on **macOS**, using a mouse or Mac trackpad does not matter. What matters is the size of the image and zoom level. 4K image: ![#76699-1.png](https://archive.blender.org/developer/F8812603/T76699-1.png) The same image is just zoomed in: ![#76699-2.png](https://archive.blender.org/developer/F8812604/T76699-2.png)

Added subscribers: @Ant3d, @HenriHebeisen, @iss

Added subscribers: @Ant3d, @HenriHebeisen, @iss

OK. I tried setMouseCoalescingEnabled, in general, it helps a lot.

/* Enable or disable coalescing of mouse movement events, including mouse moved, mouse dragged, and tablet events. Coalescing is enabled by default. */
--- a/intern/ghost/intern/GHOST_SystemCocoa.mm
+++ b/intern/ghost/intern/GHOST_SystemCocoa.mm
@@ -890,11 +890,12 @@ - (void)windowWillClose:(NSNotification *)notification
 bool GHOST_SystemCocoa::processEvents(bool waitForEvent)
 {
   bool anyProcessed = false;
   NSEvent *event;
 
-  //  SetMouseCoalescingEnabled(false, NULL);
+  [NSEvent setMouseCoalescingEnabled:NO];
+
   // TODO : implement timer ??
 #if 0
   do {
     GHOST_TimerManager* timerMgr = getTimerManager();
 

I found a similar fix for Krita:
https://phabricator.kde.org/D7880

And this:
https://lists.blender.org/pipermail/bf-blender-cvs/2010-June/028869.html

+ (void)setMouseCoalescingEnabled:(BOOL)flag;
+ (BOOL)isMouseCoalescingEnabled;

when precision tool starts (mouse/pen down)
  [NSEvent setMouseCoalescingEnabled: NO];

when precision tool stops (mouse/pen up)
  [NSEvent setMouseCoalescingEnabled: YES];

At least we can call it confirmed.

OK. I tried `setMouseCoalescingEnabled`, in general, it helps a lot. ``` /* Enable or disable coalescing of mouse movement events, including mouse moved, mouse dragged, and tablet events. Coalescing is enabled by default. */ ``` ``` --- a/intern/ghost/intern/GHOST_SystemCocoa.mm +++ b/intern/ghost/intern/GHOST_SystemCocoa.mm @@ -890,11 +890,12 @@ - (void)windowWillClose:(NSNotification *)notification bool GHOST_SystemCocoa::processEvents(bool waitForEvent) { bool anyProcessed = false; NSEvent *event; - // SetMouseCoalescingEnabled(false, NULL); + [NSEvent setMouseCoalescingEnabled:NO]; + // TODO : implement timer ?? #if 0 do { GHOST_TimerManager* timerMgr = getTimerManager(); ``` I found a similar fix for Krita: https://phabricator.kde.org/D7880 And this: https://lists.blender.org/pipermail/bf-blender-cvs/2010-June/028869.html ``` + (void)setMouseCoalescingEnabled:(BOOL)flag; + (BOOL)isMouseCoalescingEnabled; when precision tool starts (mouse/pen down) [NSEvent setMouseCoalescingEnabled: NO]; when precision tool stops (mouse/pen up) [NSEvent setMouseCoalescingEnabled: YES]; ``` At least we can call it confirmed.

From what I can find that's the appropriate fix. I can't find any way to extract mouse event "history" from a coalesced mouse event, and some non-Apple documentation states that the behavior of coalescing is to clobber the unprocessed mouse event in the event queue. A similar W3C thread makes no mention of an history extracting function for macOS.

I would move disabling coalescing to system initialization instead of event processing since running it every frame should be unnecessary. I think a PR with this change would be accepted.

From what I can find that's the appropriate fix. I can't find any way to extract mouse event "history" from a coalesced mouse event, and some non-Apple documentation states that the behavior of coalescing is to clobber the unprocessed mouse event in the event queue. A similar [W3C thread ](https://lists.w3.org/Archives/Public/public-pointer-events/2014AprJun/0057.html) makes no mention of an history extracting function for macOS. I would move disabling coalescing to system initialization instead of event processing since running it every frame should be unnecessary. I think a PR with this change would be accepted.

Afaik the point is to disable coalescing, not enable it

Afaik the point is to disable coalescing, not enable it

@PrototypeNM1 Just disable coalescing at system initialization will affect the performance of other operations, such as rotating the 3D view or change values (recalculation) by dragging button. I think this should only be disabled if necessary. I guess, I don't really understand how it works.

@PrototypeNM1 Just disable coalescing at system initialization will affect the performance of other operations, such as rotating the 3D view or change values (recalculation) by dragging button. I think this should only be disabled if necessary. I guess, I don't really understand how it works.

You can coalesce events in software, instead of depending on system to do it

You can coalesce events in software, instead of depending on system to do it

I guess the commented out code below setMouseCoalescingEnabled is exactly intended for this:
https://developer.blender.org/diffusion/B/browse/master/intern/ghost/intern/GHOST_SystemCocoa.mm$895

I guess the commented out code below setMouseCoalescingEnabled is exactly intended for this: https://developer.blender.org/diffusion/B/browse/master/intern/ghost/intern/GHOST_SystemCocoa.mm$895

In #76699#1047523, @sheerun wrote:
Afaik the point is to disable coalescing, not enable it

Coalescing can mean to bundle the events together and optionally allow unpacking them, as is the case on Windows. This is preferable behavior as it allows batch processing of similar OS events.

Unfortunately this doesn't seem to be an option on macOS, which uses coalesce to mean overwriting a singular unprocessed event.

In #76699#1047562, @jenkm wrote:
@PrototypeNM1 Just disable coalescing at system initialization will affect the performance of other operations, such as rotating the 3D view or change values (recalculation) by dragging button. I think this should only be disabled if necessary. I guess, I don't really understand how it works.

Blender coalesces mouse input in a separate step - in the Window Manager if you're curious. Operators which don't need all mouse input don't receive all mouse input. The default behavior should be to consume all available mouse events at all times.

> In #76699#1047523, @sheerun wrote: > Afaik the point is to disable coalescing, not enable it Coalescing can mean to bundle the events together and optionally allow unpacking them, as is the case on Windows. This is preferable behavior as it allows batch processing of similar OS events. Unfortunately this doesn't seem to be an option on macOS, which uses coalesce to mean overwriting a singular unprocessed event. > In #76699#1047562, @jenkm wrote: > @PrototypeNM1 Just disable coalescing at system initialization will affect the performance of other operations, such as rotating the 3D view or change values (recalculation) by dragging button. I think this should only be disabled if necessary. I guess, I don't really understand how it works. Blender coalesces mouse input in a separate step - in the Window Manager if you're curious. Operators which don't need all mouse input don't receive all mouse input. The default behavior should be to consume all available mouse events at all times.

Blender coalesces mouse input in a separate step - in the Window Manager if you're curious. Operators which don't need all mouse input don't receive all mouse input. The default behavior should be to consume all available mouse events at all times.

The mouse input only as I can see. I use a trackpad (MOUSEPAN, MOUSEROTATE) and the 3D view rotation is very laggy with disabled coalescing. Enabling the Auto Depth option gives 3-5 fps.

> Blender coalesces mouse input in a separate step - in the Window Manager if you're curious. Operators which don't need all mouse input don't receive all mouse input. The default behavior should be to consume all available mouse events at all times. The mouse input **only** as I can see. I use a trackpad (`MOUSEPAN`, `MOUSEROTATE`) and the 3D view rotation is very laggy with disabled coalescing. Enabling the Auto Depth option gives 3-5 fps.

Could this be enabled for mouse events only and fixed for other events in separate issues?

Could this be enabled for mouse events only and fixed for other events in separate issues?

Added subscribers: @ArtoKitula, @brecht

Added subscribers: @ArtoKitula, @brecht

In #76699#1048933, @jenkm wrote:

Blender coalesces mouse input in a separate step - in the Window Manager if you're curious. Operators which don't need all mouse input don't receive all mouse input. The default behavior should be to consume all available mouse events at all times.

The mouse input only as I can see. I use a trackpad (MOUSEPAN, MOUSEROTATE) and the 3D view rotation is very laggy with disabled coalescing. Enabling the Auto Depth option gives 3-5 fps.

Applying an overwrite behavior similar to what macOS does (discard all but the most recent, unprocessed, successive ghost trackpad pan/rotate/pinch events) would work in the Window Manager. The logic would be similar to how mouse input is coalesced by the same module.

I'm not sure if that's the preferred behavior, @brecht @ArtoKitula could you weigh in on the above?

> In #76699#1048933, @jenkm wrote: >> Blender coalesces mouse input in a separate step - in the Window Manager if you're curious. Operators which don't need all mouse input don't receive all mouse input. The default behavior should be to consume all available mouse events at all times. > > The mouse input **only** as I can see. I use a trackpad (`MOUSEPAN`, `MOUSEROTATE`) and the 3D view rotation is very laggy with disabled coalescing. Enabling the Auto Depth option gives 3-5 fps. Applying an overwrite behavior similar to what macOS does (discard all but the most recent, unprocessed, successive ghost trackpad pan/rotate/pinch events) would work in the Window Manager. The logic would be similar to how mouse input is coalesced by the same module. I'm not sure if that's the preferred behavior, @brecht @ArtoKitula could you weigh in on the above?

We should implement coalescing for trackpad events in WM, and then disable coalescing in GHOST.

For the WM part, something like this should work (untested): P1757

We should implement coalescing for trackpad events in WM, and then disable coalescing in GHOST. For the WM part, something like this should work (untested): [P1757](https://archive.blender.org/developer/P1757.txt)

@jenkm looks like there's a clear path to resolving this issue. Do you plan to submit a diff? I'd pick it up but I don't have hardware to test.

@jenkm looks like there's a clear path to resolving this issue. Do you plan to submit a diff? I'd pick it up but I don't have hardware to test.

It seems to work, but I'm not sure I can judge if everything is working correctly. I might be missing something. So this task is not for me.

It seems to work, but I'm not sure I can judge if everything is working correctly. I might be missing something. So this task is not for me.
Nicholas Rishel self-assigned this 2020-11-14 20:52:38 +01:00

Changed status from 'Needs Developer To Reproduce' to: 'Confirmed'

Changed status from 'Needs Developer To Reproduce' to: 'Confirmed'

@sheerun @jenkm could you test this build ? If it works could you also confirm the following:

  • Is the issue still fixed if you open and draw on a second Blender window?
  • Do trackpad gestures still work correctly?
@sheerun @jenkm could you test [this build ](https://builder.blender.org/download/temp_macos_coalesced_tablet/)? If it works could you also confirm the following: - Is the issue still fixed if you open and draw on a second Blender window? - Do trackpad gestures still work correctly?

[NSEvent setMouseCoalescingEnabled:NO] has no effect inside the the GHOST_SystemCocoa() or init()

wm_event_free_last should be static

`[NSEvent setMouseCoalescingEnabled:NO]` has no effect inside the the `GHOST_SystemCocoa()` or `init()` `wm_event_free_last` should be `static`

This issue was referenced by 96200110eb

This issue was referenced by 96200110eb0f0c8d2d48b1f383927ab8bd6c4aff

@jenkm Tried a different approach, moving [NSEvent setMouseCoalescingEnabled:NO] into the applicationDidFinishLaunching callback, updated build here .

@jenkm Tried a different approach, moving `[NSEvent setMouseCoalescingEnabled:NO]` into the `applicationDidFinishLaunching` callback, updated build [here ](https://builder.blender.org/download/temp_macos_coalesced_tablet/).

@girafic you might be interested in this thread and the above test build.

@girafic you might be interested in this thread and the above test build.

Changed status from 'Confirmed' to: 'Resolved'

Changed status from 'Confirmed' to: 'Resolved'

@PrototypeNM1 working fine with the test build 👍

@PrototypeNM1 working fine with the test build 👍
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
9 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#76699
No description provided.