ImageGlass icon indicating copy to clipboard operation
ImageGlass copied to clipboard

Bad performance when panning large images

Open Keith94 opened this issue 7 years ago • 16 comments

Steps to reproduce

  1. Open a very large image (15+ MB), eg https://eoimages.gsfc.nasa.gov/images/imagerecords/78000/78314/VIIRS_3Feb2012_lrg.jpg
  2. Press Ctrl++ to zoom in
  3. Click and drag on the image to pan/drag

Expected results

Smooth and responsive performance while panning

Actual results

Extremely bad performance/frame rate while panning

System info:

  • ImageGlass version: 4.5.11.14
  • OS version: Windows 10

Keith94 avatar Nov 15 '17 02:11 Keith94

The issue is that the image dimension is too big to ImageGlass 12000x12000. I think this is the threshold

d2phap avatar Dec 01 '17 02:12 d2phap

I just logged in to say that I've downloaded the image and used the latest stable version of ImageGlass to view it.

Zooming was instantaneous while panning was a little bit slow but I wouldn't class it as extremely bad performance.

I am using a laptop with Win 10 Pro 64 bit, i5-5200U and 8GBs of RAM. So is there any chance that zooming/panning is not only software related but hardware related as well?

@Keith94 do you have a better computer where you could test the same image?

SonamorN avatar Dec 13 '17 09:12 SonamorN

@rNianios I don't, but if you test the image against another software e.g. Windows 10 Photos app / Firefox Nightly, the difference is very noticeable, and performance is buttery smooth.

Keith94 avatar Dec 14 '17 01:12 Keith94

The problem here is that ImageGlass does not use your video card to hardware-accelerate the rendering process. This problem is exasperated if you enable "Smooth pixels" as a zoom optimisation under Settings > Image > Zooming, zoom in and out and then pan around a zoomed in image of ANY size (doesn't have to be a massive file size. It is sluggish and unresponsive.

The reason is easy to see. Open Task Manager while panning or zooming in ImageGlass and you'll notice the CPU spike up to 20-30% with a 0% load on the GPU. Do the same in Windows 10 Photo viewer and it elegantly handles the workload by efficiently assigning up to a 15% load onto my GTX 1080 while reducing the workload on the CPU. Since the video card is very good at this type of work, Photos is able to handle very smooth zooming and panning even while smoothing the pixels when zoomed in.

I am trying to replace the Windows 10 "Photo" app with something better as it is pretty frustrating in many ways. ImageGlass was looking like it might be on the way to achieving that goal but unfortunately, not having GPU rendering is an absolute deal breaker for me. As a picture viewer, if you can't pan or zoom smoothly on a picture.. well that's the main function a picture viewer should be able to handle well and sadly, this isn't up to scratch!

@d2phap I had a look but didn't notice any options to enable GPU rendering. Is this a possibility with the existing software or something you could look into adding? As mentioned, it really is a deal breaker and prevents me from considering this software. I suspect it's a deal breaker for others too but they just see it as "too laggy."

BinaryLoopCode avatar Jan 13 '19 09:01 BinaryLoopCode

Hi @BinaryLoopCode IG is build on winforms technology which is not hardware-accelerated. So this is a limitation, i am still looking for a better solution.

d2phap avatar Jan 13 '19 11:01 d2phap

+1 for this. UI wise the program is pretty much covered, so after the color management was implemented this is the last bit remain. Just posting so I can keep track of the issue.

Dogway avatar Feb 03 '19 12:02 Dogway

Any updates on whether hardware acceleration will be implemented? This would make an already brilliant image viewer even better, especially for mobile (Laptop, tablet, etc.) users as it helps conserve battery since the GPU is better suited for such tasks. Likewise, it gives an edge over what appears to be almost every other third party image viewer which also seem to lack hardware acceleration of any kind.

I see @d2phap's request for Hardware Acceleration to be added to WinForms was rejected, but how about WPF? I believe WPF does feature hardware acceleration, although my own experience with using WPF is quite limited so I am unable to provide further information (or a real idea of how much of a pain it would be to switch over and/or any constraints WPF brings).

Hazbelll avatar Jan 22 '20 01:01 Hazbelll

To update here, I am working on an UWP version. It will take some time. There will be preview versions.

d2phap avatar May 02 '20 15:05 d2phap

@d2phap https://devblogs.microsoft.com/dotnet/windows-forms-designer-for-net-core-released/ this might be a partial solution for this situation. Since the newer builds are using at least .NET Framework 4.8 now; when VS 2019 16.7 is ready, we could try re-targeting against .NET Core 3 or 5 (whatever's out at that point), and see how it all works.

unquietwiki avatar Jul 12 '20 23:07 unquietwiki

Any update about gpu rendering yet? Everythign is perfect except hardware acceleration.

rohitghali avatar Aug 31 '21 05:08 rohitghali

To update, hardware acceleration is partially supported in v9 (only for non-alpha formats), and the performance for panning, zooming is also significantly improved when it's on.

  • [x] Direct2D does not display image with alpha formats correctly (or I haven't known yet), so IG will switch to GDI+
  • [x] GDI+ is still the best for GIF animation: speedy, less resource.
  • [x] Direct2D only supports the texture dimension up to 16384 pixels: https://docs.microsoft.com/en-us/windows/win32/direct3d11/overviews-direct3d-11-devices-downlevel-intro?redirectedfrom=MSDN#feature-support-for-feature-levels-12_2-through-9_3. If the image is larger than it, it does not show.
  • [ ] I'm going to use GDI to handle the non-alpha image larger than 16384 px.

IG v9 is still under active development. The first beta is targeting by end of March. You can check the progress at https://github.com/d2phap/ImageGlass/projects/11

d2phap avatar Mar 19 '22 09:03 d2phap

@d2phap This would be a good time to tie in #1314 ; I think that goes in the opposite direction of GDI+, unless there's a way to tie the two together? I did find that DirectX 12 works on Windows 7 (which has been deprecated for a bit now), and that texture limit might not exist under DX12? The docs don't seem that clear; you might be able to make more sense of it.

unquietwiki avatar Mar 19 '22 09:03 unquietwiki

DirectX12 is the latest version of DirectX, but it only supports up to 16384px. IG v9 just uses a small features of Direct2D (it's quite complicated to me).

I have another plan for v10 that is to only support for Windows 10 (64-bit) or later, use WinUI 3 (or MAUI). I could do it for v9 already, but IG still has lots of Windows 7 users. So supporting GPU in v9 will make those who can't upgrade to Windows 10 or later happy. WinUI 3 is still very buggy and its APIs are still unfriendly. Hopefully by the time, it will get much better.

d2phap avatar Mar 19 '22 09:03 d2phap

@d2phap I've been hearing good things about MAUI. This will more or less put my old "Billgatus of BORG" poster to rest for good. 😆

unquietwiki avatar Mar 19 '22 09:03 unquietwiki

DirectX12 is the latest version of DirectX, but it only supports up to 16384px. IG v9 just uses a small features of Direct2D (it's quite complicated to me).

I have another plan for v10 that is to only support for Windows 10 (64-bit) or later, use WinUI 3 (or MAUI). I could do it for v9 already, but IG still has lots of Windows 7 users. So supporting GPU in v9 will make those who can't upgrade to Windows 10 or later happy. WinUI 3 is still very buggy and its APIs are still unfriendly. Hopefully by the time, it will get much better.

please focus on making it better and faster for those who upgraded to Windows 11, there is plenty of image viewer already and they will not be left behind unless they are willing for... WinUI 3 is getting better lately and GPU acceleration is a must, even some light AI based functions would be very welcome... IrfanView is more than enough for Windows 7 users 99% of the time

neoOpus avatar Jun 05 '22 15:06 neoOpus

  • [x] v9.0 beta 2 added support GPU rendering for transparent image formats. The maximum image dimension is till 16384 x 16384 pixels.
  • [x] Animated GIF/WEBP format is still use GDI+ for less resource.
  • [x] Supports smooth & precise zooming by keyboard / trackpad.
  • [x] Supports smooth panning by keyboard when enabling Image Focus mode.
  • [x] Switching Direct2D/GDI+ <-> GDI is too complicated. In v9.0 beta 3, I will resize the image to 16384 if it is larger than that number.

d2phap avatar Sep 06 '22 14:09 d2phap

ImageGlass Moon 9.0 beta 3 is released with support open the image that is larger than 16384 by scaling it down to 16384px. So this is it for now.

d2phap avatar Dec 24 '22 08:12 d2phap