Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Mouse cursor is captured at the wrong size, for non-default cursor sizes #2604

Closed
chris-morgan opened this issue Mar 30, 2020 · 10 comments
Labels
Confirmed This bug report has been confirmed by project members Windows Affects Windows

Comments

@chris-morgan
Copy link

Platform

Operating system and version: Windows 10 (20H1; version 2004, build 19041.172)
OBS Studio version: 25.0.1 (64-bit, windows)
Hardware: Surface Book, high-DPI screen (2× scaling factor, potentially relevant here).

Expected Behavior

OBS Studio should capture the mouse cursor with the same size and appearance as it has on screen.

(Sorry, no screenshot, because Windows doesn’t capture the cursor in screenshots, and ShareX which does suffers from much the same bug, and I’m too lazy right now to synthesise equivalent screenshots.)

Current Behavior

My mouse cursor is captured in the correct colour, but not at the correct size.

At sizes 1–7, OBS Studio draws the cursor at size 1.

At sizes 8–15, OBS Studio draws the cursor at the true size, then at size 1 on top of that.

Steps to Reproduce

  1. Be using at least the major version of Windows 10 from the second half of 2019, when this new cursor sizing and colouring interface was added. (It may have existed previously, I don’t know; but the interface for it is fairly new.)
  2. In Windows’ Settings app, Ease of Access → Mouse pointer → Change pointer size, increase it from 1 to some other value. The largest value, 15, will make it super-obvious, because your mouse pointer will now be 150 pixels tall, which is arguably excessive.
  3. In OBS Studio, Add → Display Capture, and in its properties, tick Capture Cursor.
  4. Twiddle the pointer size slider in the Settings app, and watch how it appears in OBS Studio.

Additional Information

Related issues for which I shan’t file bugs:

  • switching pointer colour (white, black, inverted, any coloured) doesn’t seem to take effect until you restart OBS Studio, or maybe something else can trigger it because I don’t think I restarted OBS but a couple of times when I came back a few minutes later it was the right colour? (Not filing because it’s such a niche thing, but maybe it’ll get fixed as part of this?)
  • The size 1 inverted cursor is just black, not inverted. The size 8+ cursor is inverted properly. (Not filing because I suspect it may be fixed as part of this—it looks like there are two code paths, one right and one wrong, if the wrong is dropped then it all pans out—and I don’t use an inverted cursor myself anyway.)

The bug I am reporting here was previously reported in #2258, but rapidly closed because it was improperly filed.

@UserNaem
Copy link

OBS doesn't really "capture" the mouse pointer, it just draws one exactly where the real one would be. And it doesn't respect your mouse pointer scaling settings.
You can work around this by using a custom mouse pointer in the size you want.

@chris-morgan
Copy link
Author

Yeah, it draws one, but it draws it incorrectly. That’s the bug. Also note how I report that for size 8 and beyond it draws the cursor both correctly and incorrectly.

@WizardCM WizardCM added Confirmed This bug report has been confirmed by project members Windows Affects Windows labels Aug 25, 2020
@WizardCM
Copy link
Member

OK, I did some extensive testing on this today. Here's what I figured out.

  • When you see double cursors (in Display Capture), one is being rendered in the Duplicator API's texture directly (ie. Software Cursor), and the second one is being rendered by our cursor helpers.
  • Window Capture uses its own cursor rendering functions, rather than our cursor helpers
  • Every time you see a cursor that is the wrong size, it's our code. Whenever you see a cursor that is the correct size, that's Microsoft's code (specifically, a software cursor)

As described by @VodBox (who helped me debug this):

When using the Desktop Duplication API (which we do on Win 8+), the texture we receive will already include a cursor whenever a software cursor is being used by Windows. The correct procedure we're supposed to follow is to check from the data returned by AcquireNextFrame whether a hardware cursor is visible, and therefore whether we should draw it ourselves, and also whether the pointer shape has changed. In order to get the right pointer shape to draw, we're supposed to call GetFramePointerShape to retrieve the shape as pixel data.

Currently in OBS, when capture cursor is enabled, Display Capture will draw the cursor on every frame. It'll also use old Win32 APIs (GetCursorInfo, GetIconInfo, GetObject, GetBitmapBits) for getting information about the cursor to draw. These functions on Windows 10 seem to not reflect the true size of any cursor.

I don't think the APIs we currently use in the helper functions (starting with GetCursorInfo) have the ability to give us correctly-sized textures. My guess is that as it's a legacy API (Windows 2000-era), it will always recieve a 32x32 icon for compatibility reasons, and getting more modern cursors should be done with newer APIs (ie GetFramePointerShape, Windows 8+).

@chllcy
Copy link

chllcy commented Sep 11, 2020

hi @WizardCM the gdi draw cursor is slow,will obs support the new api?

@WizardCM
Copy link
Member

@chllcy As this is relatively low priority and I don't have the skill, nobody is currently looking into this further.

@EposVox
Copy link
Contributor

EposVox commented Dec 2, 2020

I am running into this as well, with my cursor being tiny in the capture - very frustrating. This used to happen w/ mixed scaling % but I'm on same scaling on both monitors and it's still an issue.

@SamGG
Copy link

SamGG commented Feb 10, 2021

I faced the same problem with OBS 26.1.1 64bits Win10.
I solved it by changing the cursor size and shape in the "old" mouse settings panel. I chose a large cursor but I could also add a cursor with a yellow halo (there are many on internet). And it works: OBS is using this cursor during the recording. I guess OBS refers to this cursor setting but not to the scaling proposed in the mouse panel of Windows 10. To access the old mouse settings, click on the Windows icon in the task bar, and then type main.cpl and go to cursors. I think that is what @UserNaem was meaning.
@EposVox @chris-morgan this really does the job and your frustration will disappear as mine.
@WizardCM My thanks to the devel team: continue providing this incredible piece of software called OBS.

@RytoEX
Copy link
Member

RytoEX commented Sep 22, 2022

Confirmed that this only occurs when using DXGI Display Capture (Display Duplicator API). This does not happen when using the WGC Display Capture (Windows 10 1903+) and OBS Studio 25+, which we now recommend in nearly all cases.

@eobet
Copy link

eobet commented Aug 26, 2023

It's 2023 and I still see this the capture selection in OBS is this:

image

OBS 29.13 was set to automatic (and I'm using a Geforce 3090). Why is it defaulting to a non recommended capturing method if what @RytoEX said still applies? I had to do an internet search to figure out why the cursor was capturing the wrong size.

@RytoEX
Copy link
Member

RytoEX commented Aug 26, 2023

I said that we recommend "Windows 10 (1903 and up)" "in nearly all cases". If using it causes a problem for you and your setup, and the other one does not, then we don't recommend it. In nearly all other cases (default cursor size), it works just fine and in some cases does not suffer from issues that "DXGI Desktop Duplication" does (like not working on laptops).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Confirmed This bug report has been confirmed by project members Windows Affects Windows
Projects
None yet
Development

No branches or pull requests

8 participants