MagickWand and Threading

The MagickWand interface is a new high-level C API interface to ImageMagick core methods. We discourage the use of the core methods and encourage the use of this API instead. Post MagickWand questions, bug reports, and suggestions to this forum.
Post Reply
NitroPye

MagickWand and Threading

Post by NitroPye » 2010-12-13T13:56:49-07:00

I'm doing a bunch of image processing in a GUI application so processing the images in a background thread is ideal but I've come up against an issue.

MagickReadImage, MagickWriteImage, and MagickResizeImage all cause a EXC_BAD_ACCESS in the background. MagickGetImageWidth, MagickSetImageResolution and a handful of other functions do not cause any issues in the background. The immediete solution was to call the offending functions on the main thread and wait until they are done but this is less than ideal as it locks up the UI.

I guess my first question would be is are the functions I am having issues with even usable in background threads?

If any more detailed information is needed from the debugger let me know.

Thanks in advance.

User avatar
magick
Site Admin
Posts: 10996
Joined: 2003-05-31T11:32:55-07:00

Re: MagickWand and Threading

Post by magick » 2010-12-13T17:42:22-07:00

Which version of ImageMagick are you using? Try building ImageMagick without OpenMP support, add --disable-openmp to your configure script command line and rebuild / reinstall. If it still fails, we'll need a small program we can download and reproduce the problem before we can comment further. ImageMagick is designed and tested to be thread safe but perhaps your program creates a condition we have not tested yet.

NitroPye

Re: MagickWand and Threading

Post by NitroPye » 2010-12-13T18:05:38-07:00

I am running version 6.6.6-3. It was built with macports. No new updates in the ports tree. I went ahead and applied this patch to my portfile which effectively will apply the no openmp configure flag when building ImageMagick.

This fixed the issue. Can't say I know enough about threading and the like to fully understand what the issue is, but disabling openmp fixed it.

Cheers

Post Reply