fix: address pipeline-reliability verify findings
Close the source image after converting to RGBA so PNGs at the pixel limit fit the render memory limit. Strengthen the fencing test so that it fails without the attempt check, and measure worker and relay stops under load. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -335,6 +335,36 @@ def png_rgba_large(width: int = 8000, height: int = 5000) -> bytes:
|
||||
return buffer.getvalue()
|
||||
|
||||
|
||||
def png_at_pixel_limit(
|
||||
color: int,
|
||||
depth: int,
|
||||
*,
|
||||
transparent: bool = False,
|
||||
width: int = 8000,
|
||||
height: int = 5000,
|
||||
) -> bytes:
|
||||
"""PNG любого типа на 40 млн пикселей из нулей: файл мал, а декодирование
|
||||
разворачивает все пиксели. `transparent` — чанк tRNS (прозрачный цвет):
|
||||
Pillow открывает такой файл без альфы и переводит в RGBA отдельным шагом."""
|
||||
row = b"\x00" * (1 + (width * depth * _CHANNELS[color] + 7) // 8)
|
||||
compressor = zlib.compressobj(9)
|
||||
parts = [compressor.compress(row) for _ in range(height)]
|
||||
parts.append(compressor.flush())
|
||||
data = png(
|
||||
width,
|
||||
height,
|
||||
color=color,
|
||||
depth=depth,
|
||||
idat=b"".join(parts),
|
||||
)
|
||||
if not transparent:
|
||||
return data
|
||||
# tRNS — после IHDR и PLTE (перед первым IDAT): у палитры индекс, иначе цвет
|
||||
index = data.index(b"IDAT") - 4
|
||||
body = b"\x00" if color == 3 else b"\x00" * (6 if color == 2 else 2)
|
||||
return data[:index] + chunk(b"tRNS", body) + data[index:]
|
||||
|
||||
|
||||
def png_stripes(
|
||||
stripes: tuple[tuple[int, tuple[int, int, int]], ...] = (
|
||||
(100, (255, 0, 0)),
|
||||
|
||||
Reference in New Issue
Block a user