ShareX / ShareX

ShareX is a free and open source program that lets you capture or record any area of your screen and share it with a single press of a key. It also allows uploading images, text or other types of files to many supported destinations you can choose from.
https://getsharex.com
GNU General Public License v3.0
28.27k stars 3.11k forks source link

Noticeable lag when capturing region - crosshairs skip before beginning capture #3132

Closed GlitterHorn closed 4 years ago

GlitterHorn commented 6 years ago

This is kind of hard to explain, so I'm also attaching a GIF of the repro.

More recently I've noticed that region capture is lagging. If I start a capture, when I hold down the left mouse button and drag to select a region, the crosshairs skip pretty significantly before the capture window appears.

If I hold down the mouse button and wait a few seconds before dragging, this doesn't happen, and the selection window appears where I want it to (where the crosshairs are on the screen when I click-and-hold the left mouse button).

It's like it's not registering that I've clicked the mouse button. The second file is the same action but with mouse clicks highlighted - the blue dot showing a mouse click doesn't appear until the region window appears, even though I'm clicking-and-holding when the crosshairs are in the upper right corner of the area shown.

sharex repro

sharex repro 2

Scrxtchy commented 6 years ago

If you click the cog on the right hand side of the capture taskbar, and enable the FPS counter, does it display 0 when the screen freezes?

GlitterHorn commented 6 years ago

It does at first, yes. It hits 6fps when I'm dragging the region box.

dasebasto commented 6 years ago

This problem occasionally occurs on my PC too.

campbeb commented 6 years ago

Can you provide some specifics on your setup? What version of Windows? Is ShareX installed or portable? Has ShareX been running a long time when this occurs? How are you initiating the screen capture?

If we can find any similarities between people who have this issue, then maybe we can figure out why.

dasebasto commented 6 years ago

My setup: Hardware has decent specs: Intel i7-6700HQ with 16GB RAM. OS: Windows 10, version 1709, build 16299.309 Screens: 2 x 2560x1440 monitors ShareX 12.1.1, installed (not portable).

Has ShareX been running a long time when this occurs? --> not necessarily (I managed to reproduce after a fresh start of the app)

How I capture: Capture region (transparent), using hotkey.

Importance of the lag varies greatly (from 0 to ~50 pixels), even between tests in a series done in the same conditions. I'm usually able to reproduce in less than 10 tries.

CPU usage seems abnormally high during capture, even before actually moving the mouse and starting selecting the region: sharex_2018-04-06_13-56-15

dasebasto commented 6 years ago

Transparency seems to be the culprit.

High CPU usage and lag issues both go away when using Capture Region or Capture Region (Light).

I don't need transparency, so I'll stick to these simple modes for everyday use.

GlitterHorn commented 6 years ago

Mine skips regardless of which region capture type I use.

bmartus commented 5 years ago

I am getting the same type of issue, no matter which region capture type I use also.

Surface Book with two 28" Dell 4K monitors attached via Surface Dock.

image

jwdinkel commented 5 years ago

I've seen this also. I think these Intel i7 CPUs just aren't made for running multiple 4k monitors... I don't have the problems with more powerful CPUs...

madmisser commented 5 years ago

I can confirm I have the same issue when with 2 x 2k monitors on my laptop. The issue disappears when I disconnect external monitors and do the same test on integrated screen only. So this must be related to low power cpu/vga not being able to cope with pixel amount.

mortenmoulder commented 5 years ago

Same issue here and it's really annoying. Works fine at home with a less powerful system, but at my work I run 4 monitors with 2560x1440 resolution.

Specs:

4x 2560x1440 monitors i7-7700k 32GB RAM 512GB 970 EVO

lanes100 commented 5 years ago

Having this same issue regardless of the capture mode. Ryzen 5 1600 GTX 1070 16 GB RAM Samsung 500 GB M.2 NVME SSD where sharex installed not even at 50%

ru-errorist commented 5 years ago

I guess my experience somehow correlated with yours. Using virtual machine as a sandbox for research, connection is local and stable, never had any issues even with video playback. But taking region screenshots is painful: 2019 05 31_11-32-46_feNM9

As being a virtual machine, it has decent amount of memory and CPU but low on video: 2019 05 31_11-47-13_RDCMan_8McTgiOrJB 2019 05 31_11-48-11_RDCMan_8S0X0JH7f0

lanes100 commented 5 years ago

bumping this bc i know how to reproduce it

reproduction factors: use a 4k monitor

All monitors now should lag as shown above.

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

nienkevanunen commented 3 years ago

I'm still experiencing this on Dell XPS 13 with 4k touchscreen, when using the regular capture region (not light or transparent). At first I blamed my trackpad changing position after clicking or something, but then I noticed it happened too when I was using a regular mouse. ShareX version is 13.1.

Scrxtchy commented 3 years ago

The real issue is that the performance of the capture tool scales badly at higher resolutions. I get about 43fps at the 1080x5760 resolution that my desktop uses. Even less when I have a fourth display attached. But I notice how badly this scales when I disable monitors and the performance skyrockets closer to my monitors update speed.

Doing a CPU profile displays that most of the time goes to this line https://github.com/ShareX/ShareX/blob/eabb0c8b234dddf19731247d7a029df82bdb4bfe/ShareX.ScreenCaptureLib/Forms/RegionCaptureForm.cs#L735 which is responsible for displaying the captured fullscreen image image for region selecting, as it has to be done for every frame

Joakim432710 commented 3 years ago

For anyone with this problem, I have a branch with WIP https://github.com/Joakim432710/ShareX/tree/feature/regioncaptureform-4k-optimization here that utilizes Direct2D for rendering the region capture form instead, there is still some work to be done & code to be cleaned up but for now I'm using it on a day-to-day basis, and other than DPI issues it's pretty pleasant. I've gone from 6fps to 98fps(vsynced) on 4x4k monitors configured in a 1x3 + 1 monitor above the others layout which usually results in sharex creating a 11520 x 4320 texture for the cap tool (which is why the lag is so bad).

hbh7 commented 3 years ago

Hi @Joakim432710, Just wanted to say I tried out your build and went from 7 FPS to about 25, which is definitely a much appreciated improvement. I'd be happy to test out future changes if that helps. Hopefully more FPS is possible at some point :) Thanks!

Joakim432710 commented 3 years ago

I've been working on some more improvements, I'll update them when done

maleet commented 3 years ago

@Joakim432710 would it be possible to have a installable fork? :)

kogeki commented 1 year ago

I've been working on some more improvements, I'll update them when done

I just tried your fork and it does fix the issue with the 4k lag. However, it seems to break json parsing from custom uploaders. Also, the FPS display is locked on. Are there plans to fix this? Thanks for your work!

Wolfhound905 commented 1 year ago

Transparency seems to be the culprit.

High CPU usage and lag issues both go away when using Capture Region or Capture Region (Light).

I don't need transparency, so I'll stick to these simple modes for everyday use.

I recently came across this issue on windows 11, this above quote worked to fix the issue!

rafitamolin commented 1 year ago

As of today, this bug still occurs. In my case I have two screens, each with 2560x1080 resolution, 75Hz. The characteristics of my PC are i9-12900K, 32GB RAM, RTX 3080, Windows 11 22H2. I was using ShareX latest public version (14.1.0), now trying the latest dev version with no luck fixing it.

In my case no solution pointed out in this thread helps me, since in my hotkeys I don't use the screen capture mode with transparency, but the normal mode, and still there is lag when starting the capture.

@Jaex could you please take a lot at all the comments that have been posted since you labeled this as "Cannot reproduce", and reopen the issue? It appears to be clear that this isn't a single-user related bug. Thanks.

DAOWAce commented 1 year ago

For anyone with this problem, I have a branch with WIP https://github.com/Joakim432710/ShareX/tree/feature/regioncaptureform-4k-optimization here that utilizes Direct2D for rendering the region capture form instead,

@Joakim432710 As a non-developer.. how do we use this? There's no compiled build to download.

Also don't care if it's out of date, as the ShareX version I'm using is 2 years out of date anyway. ShareX, as I commented in another issue #1816 is practically unusable for high resolution recording now.

EDIT: Alright, well, I built the linked repo and it still has bad high-resolution performance. Don't know if we have to do anything different with settings (didn't see any new options), so that's currently a loss and now back to square 1.

grapevine2383 commented 1 year ago

I have lots of lag when trying to screen capture region with 6 4k monitors. Also an nvidia 4090 graphics card. Is hardware acceleration being used? Resource manager shows low usage on the GPU and it looks like the lag is from using up a full CPU core/thread (I use an intel 13900ks).

rafitamolin commented 1 year ago

@Jaex should reopen this.

DAOWAce commented 1 year ago

Anyone know of any alternative capture tools that can actually record high resolution (over 1920x wide) video that are as easy to use as ShareX?

Having to load up OBS and use it to record short video clips is an absolute pain.

0Ky commented 1 year ago

@DAOWAce The problem you have is not related to this particular issue, you should create a new issue instead. You can refer to issues #1816, #5384, and #5688 as they relate to your situation.

Unfortunately, there aren't many alternatives. In the official Discord server of ShareX, when I mentioned this concern, the response I received was as follows: "ShareX isn't intended for recording either high resolution nor high framerate, use OBS".

The underlying problem lies with ShareX's dependency on FFmpeg for video capture. FFmpeg leverages gdigrab that utilizes the Windows GDI (Graphics Device Interface) API, a legacy graphical subsystem present in all Windows versions. It operates mostly in the system's CPU, not the GPU. This means it doesn't take advantage of the dedicated video processing capabilities that modern GPUs provide. Consequently, attempting to capture high resolution or high framerate video with gdigrab can consume a large amount of CPU resources. This can not only slow your computer but also impact the performance of other applications, causing dropped frames and resulting in a choppy video output.

On the other hand, OBS Studio directly accesses internal buffers via the native OS API, which cuts down on additional data copying operations. This, in turn, can contribute to lower latency and improved frame rates.

DAOWAce commented 1 year ago

@0Ky There's no point creating a new issue when the first one you linked, from 2016, still serves as a hub for the issue itself, and I've already commented in it back in January.

If anyone who contributes to ShareX cared about fixing it, they'd have some response after 6.7 years that wasn't an excuse.

ffmpeg, while I don't know much about encoders, appears to support GDI, DirectShow and Desktop Duplication API (via ddagrab); the latter not being an option in ShareX, while the other two are (GDI grab vs Screen Recorder). Both GDI grab and DShow still run very poorly in ShareX, almost no difference between them, using GPU or CPU encoding.

Additionally, in this issue, @Joakim432710 created a fork that used Direct2D instead, but despite building it, it didn't seem to offer any improvement. I don't know if I performed the operation correctly, or if there's some other steps I have to do to utilize the D2D path within ShareX's settings. That or I just misunderstood things entirely and it was specifically for ShareX's overlay running slow, which I've never experienced.

Regardless, you're right, this issue isn't suited to my issue, but I think anyone looking for alternative software (that isn't OBS) can fit anywhere, as it shows the frustrations with ShareX and lack of any resolution, even after a number of years.

Arecsu commented 11 months ago

@DAOWAce I came across wcap and so far, it works great and it's incredibly lightweight. Uses GPU or CPU, the codecs of Windows and access the same last-gen APIs as OBS. H264 or H265, WASAPI audio. Just awesome.

EnigmaticaGH commented 4 months ago

I was getting really poor screen capture performance on a Dell XPS 17 with an attached 4k monitor. After going into Task Settings -> Capture and checking "Restrict region capture and cursor within the active monitor", I went from 10-15 fps to around 40.

hbh7 commented 4 months ago

@EnigmaticaGH, great find! I saw similar gains from around 10 fps to about 50.

spiwar commented 2 months ago

I was getting really poor screen capture performance on a Dell XPS 17 with an attached 4k monitor. After going into Task Settings -> Capture and checking "Restrict region capture and cursor within the active monitor", I went from 10-15 fps to around 40.

Thanks, makes ShareX way more usable on my 4k display, still not perfect though. @Jaex Any chance we can get this reopened and fixed?