Closed creachadair closed 1 year ago
For the record, this is the macro spec:
{
"id": 2,
"templateID": 2,
"creator": -1,
"createdAt": "2023-04-01T21:02:23.841803Z",
"textOverlay": [
{
"text": "belligerent badness",
"field": {
"x": 0.2,
"y": 0.5
},
"color": "white",
"strokeColor": "black"
}
],
"upvotes": 1
}
And the template image dimensions are:
% identify /tmp/tmemes/templates/2.png
/tmp/tmemes/templates/2.png PNG 971x544 971x544+0+0 8-bit sRGB 897163B 0.000u 0:00.002
We figured out what went wrong: A font.Face
is not required to be safe for concurrent use, and we were (sometimes) using them concurrently from the cache.
Since the collision would only happen for multiple images that request the same point size, the problem would "disappear" after reloads, since usually someone wins the race and the macro gets regenerated, making it no longer a contender.
On my local test instance, I occasionally get the attached panic during macro generation. I don't know exactly what triggers it, but this seems to work:
rm /tmp/tmemes/macros/*
).Maisem and I speculate this may be related to trying to draw outside the image bounds somehow. However, interestingly if while the server is running you repeat step (1) and then (3), I have so far not been able to make it panic again in that way—and all the images get generated OK. This maybe suggests the rendering library is keeping some state that gets primed?
This is not causing a lot of problems in production, probably because the UI doesn't generate weird text positions the way some of my manual test data do.
panic.txt