Crash when zooming in max (3,600%)
Description The Program crashes when the canvas is zoomed in the maximum level (3,600%)
To Reproduce
- Open the Program
- Zoom in to max via Mouse-Wheel, or click on 3,600% at the bottom-right context menu
Additional Info When ran via commandline, the following error occurs with the crash:
Unhandled exception. System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
at Cairo.ImageSurface.GetData()
at Pinta.Core.CairoExtensions.GetPixelData(ImageSurface surface) in /home/luna/Pinta/Pinta.Core/Extensions/CairoExtensions.cs:line 1733
at Pinta.Gui.Widgets.CanvasRenderer.RenderPixelGrid(ImageSurface dst, PointI offset) in /home/luna/Pinta/Pinta.Gui.Widgets/Widgets/Canvas/CanvasRenderer.cs:line 121
at Pinta.Gui.Widgets.CanvasRenderer.Render(IReadOnlyList`1 layers, ImageSurface dst, PointI offset) in /home/luna/Pinta/Pinta.Gui.Widgets/Widgets/Canvas/CanvasRenderer.cs:line 106
at Pinta.Gui.Widgets.PintaCanvas.Draw(Context context, Int32 width, Int32 height) in /home/luna/Pinta/Pinta.Gui.Widgets/Widgets/Canvas/PintaCanvas.cs:line 192
at Pinta.Gui.Widgets.PintaCanvas.<>c__DisplayClass6_0.<.ctor>b__5(DrawingArea area, Context context, Int32 width, Int32 height) in /home/luna/Pinta/Pinta.Gui.Widgets/Widgets/Canvas/PintaCanvas.cs:line 145
at Gtk.Internal.DrawingAreaDrawFuncNotifiedHandler.<.ctor>b__4_0(IntPtr drawingArea, IntPtr cr, Int32 width, Int32 height, IntPtr userData)
Version
- Arch Linux, Hyprland
- Pinta v2.2, Compiled from source a few minutes ago
I think this is an issue with the GTK4 port - the GTK DrawingArea widget seems to now request drawing the entire zoomed-in image, not just the visible area inside the scroll window, so at 3600% zoom that's a very large image depending on your original image size ...
Happens even on 600% for me.
Doesn't crash for me, it just becomes really slow and consumes way too much memory.
Pinta 3.0 - Flatpak
I think this is an issue with the GTK4 port - the GTK DrawingArea widget seems to now request drawing the entire zoomed-in image, not just the visible area inside the scroll window, so at 3600% zoom that's a very large image depending on your original image size ...
What is the other version, and how do I switch to it?
I think this is an issue with the GTK4 port - the GTK DrawingArea widget seems to now request drawing the entire zoomed-in image, not just the visible area inside the scroll window, so at 3600% zoom that's a very large image depending on your original image size ...
What is the other version, and how do I switch to it?
I'm not sure what you mean by "other version" .. I guess Pinta 2.1? The original comment was while Pinta 3.0 was in development, which involved porting to GTK4, and I think the cause of this issue is changes in GTK 4 for how the DrawingArea widget is rendered.
I think this is an issue with the GTK4 port - the GTK DrawingArea widget seems to now request drawing the entire zoomed-in image, not just the visible area inside the scroll window, so at 3600% zoom that's a very large image depending on your original image size ...
Doing some more investigation into this, the existing approach for the canvas widget did become less efficient with the changes to how GTK4 renders widgets, and large / zoomed-in images seem to now allocate huge textures and transfer them to the GPU.
I think the future approach is to create a Gdk.Texture for the canvas (at the same size as the underlying image), and then use gtk_snapshot_append_scaled_texture with GSK_SCALING_FILTER_NEAREST to implement zooming
See also https://discourse.gnome.org/t/scaling-images-with-cairo-is-much-slower-in-gtk4/7701
There are a lot of additional details to figure out to get this fully working, but this seems very promising from a rough prototype - I was able to open a 2000x2000 image and scale to 3600% without any performance issues or increased memory usage