Loading Image in Mac's Xcode is crashing

I’m trying to load a simple set of PNG images, but It’s crashing once running the app on Xcode. Also, it’s working fine on the windows environment within VS. I tried to change the image bit from 24 to 64 and I’m stuck with the same problem. Also, I tried different procedures for loading the image.

  1. load image from file.
    juce::ImageFileFormat::loadFrom(File("absolute_path/image.png"));

  2. load the image from binary data.
    juce::ImageFileFormat::loadFrom(BinaryData::image_png, BinaryData::image_pngSize);

Both solutions giving the same log stack of the crash. that ends up with a Bad Access(code = 1)
on the juce::~var()

1 Like

Thanks for reporting, this issue should now be resolved:

1 Like

Question:
does this mean, image loading is currently not working on OSX?
I updated to latest JUCE 6.0.7 (i.e. not develop).
Seems loading .png images is fine there, when I just tested. Even though the patch is not in there yet (as far as I can see).

Or could it fail silently / corrupting the memory without me knowing?
Hmmm…

The issue was specifically to do with loading images with static storage duration (e.g. globals and static class members). In this case, there was a chance that the image would be loaded before the internals of the var class were set up, leading to the crash seen above. This issue did not affect loading images in other contexts, such as inside main, or app/plugin callback functions.

Ah, I see.
That explains why it works for me. No global/static images on my end.
Thanks for the fast answer!

Thanks, @reuk for your great efforts! it seems to be working now on Mac