Here's the story:
1. Margin tiles mean that we use drawPattern() instead of draw() for the background gradient, because it gets tiled into the margin.
2. drawPattern() paints into an ImageBuffer and uses that to do the pattern tiling.
There was already code in Image::drawTiled to avoid proper ImageBuffer-backed patterned drawing and instead repeatedly call draw() in the case where the tile buffer would be very large, but it was only enabled on iOS. It seems like a pretty reasonable thing to do everywhere, so let's do that (but with a bigger limit than on iOS).
3. The ImageBuffer is the size of the gradient. The gradient on this page is the size of the document. A bitmap the size of the document is nearly 2GB here.
Created attachment 232167 [details]