Skip to content

fix paintbox speed - #65

Open
jcupitt wants to merge 1 commit into
masterfrom
fix-paintbox-speed
Open

fix paintbox speed#65
jcupitt wants to merge 1 commit into
masterfrom
fix-paintbox-speed

Conversation

@jcupitt

@jcupitt jcupitt commented Aug 30, 2026

Copy link
Copy Markdown
Member

When drawing wide lines, draw_line was calling vips_image_inplace() and vips_image_wio_input() for each pixel. This triggered invalidate, and when the operation cache was full of cached getpoint() calls from the info bar, made drawing very slow.

This might fix the crashes with paint + infobar enabled too.

When drawing wide lines, draw_line was calling vips_image_inplace() and
vips_image_wio_input() for each pixel. This triggered invalidate, and
when the operation cache was full of cached getpoint() calls from the
info bar, made drawing very slow.

This might fix the crashes with paint + infobar enabled too.
@jcupitt

jcupitt commented Aug 30, 2026

Copy link
Copy Markdown
Member Author

@kleisauke this might fix the infobar crashes too, I'm not certain.

@jcupitt

jcupitt commented Aug 30, 2026

Copy link
Copy Markdown
Member Author

Ooop, nope, it just crashed again.

It's a lot quicker though, so that's nice.

@kleisauke

Copy link
Copy Markdown
Member

Nice! It does seem much faster, although I was also able to provoke a crash. :(

Looking at the doc comment for vips_image_inplace():
https://www.libvips.org/API/current/method.Image.inplace.html

How about adding the same check we added to vips_image_set() and vips_image_remove() via commit libvips/libvips@80037fc?

--- a/libvips/iofuncs/image.c
+++ b/libvips/iofuncs/image.c
@@ -3600,6 +3600,14 @@ vips__image_wio_output(VipsImage *image)
 int
 vips_image_inplace(VipsImage *image)
 {
+#ifdef DEBUG_LEAK
+	/* Warn if inplace is being called on a shared image.
+	 */
+	if (vips__leak &&
+		G_OBJECT(image)->ref_count > 2)
+		printf("vips_image_inplace: shared image %p\n", image);
+#endif /*DEBUG_LEAK*/
+
 	/* Do an vips_image_wio_input(). This will rewind, generate, etc.
 	 */
 	if (vips_image_wio_input(image))

I noticed that this warning is triggered when painting, but I'm not sure whether it's a red herring.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants