BUG (with fix): UI freeze on M1 while painting transformed image fills

The following code causes a UI freeze on M1 but not on Intel macs:

    FillType fillType;
    fillType.image = Image(Image::PixelFormat::ARGB, 2, 2, true);
    fillType.image.setPixelAt(0, 0, Colours::crimson);
    fillType.transform = AffineTransform::rotation(degreesToRadians(-33.0f));
    g.setFillType(fillType);
    g.fillRect(10, 10, 100, 100);

This is caused by the following lines:

The underlying cause is that the origin of the clip region is (+inf, +inf) and int(std::numeric_limits::infinity()) is 2147483647 on M1 and -2147483648 on Rosetta 2 and Intel. I’m aware that this is a wild claim and I wouldn’t believe it either, so there’s some proof. Run this script on a M1 mac:

cat >inf_to_int.cpp <<EOL
#include <limits>
#include <iostream>

int main()
{
    std::clog << int(std::numeric_limits<float>::infinity()) << std::endl;
}

EOL

clang++ inf_to_int.cpp -o x86_app -target x86_64-apple-macos10.12
clang++ inf_to_int.cpp -o arm_app -target arm64-apple-macos11
lipo -create -output universal_app x86_app arm_app

echo "Native M1:"
arch -arm64 ./universal_app

echo "Rosetta 2 / Intel:"
arch -x86_64 ./universal_app

Output:

Native M1:
2147483647
Rosetta 2 / Intel:
-2147483648

@reuk We fixed this by not executing the while loop when clip.size.width or clip.size.height is zero.

1 Like

Thank you for reporting. Fix here: