From 68a680169029121155720e4b07d50a21dc636110 Mon Sep 17 00:00:00 2001 From: SantaSpeen Date: Thu, 22 Oct 2026 21:58:43 +0300 Subject: [PATCH] Raise DICOM volume limit to 1 GiB and simplify image controls --- docs/dicom-viewer-options.md | 2 +- frontend/src/i18n/en.json | 6 +++--- frontend/src/i18n/ru.json | 6 +++--- frontend/src/utils/__tests__/dicom-series.test.ts | 14 ++++++++------ frontend/src/utils/dicom-series.ts | 2 +- frontend/src/utils/dicom-volume.ts | 4 ++-- scripts/build-release.ps1 | 2 +- scripts/build-release.sh | 2 +- 8 files changed, 20 insertions(+), 18 deletions(-) diff --git a/docs/dicom-viewer-options.md b/docs/dicom-viewer-options.md index d2582d11..0186f006 100644 --- a/docs/dicom-viewer-options.md +++ b/docs/dicom-viewer-options.md @@ -18,7 +18,7 @@ Объёмный режим включает вращение и масштабирование 3D, аксиальную/сагиттальную/корональную реконструкцию, прокрутку срезов, перемещение, яркость/контрастность и непрозрачность. Нужен WebGL2. На неподходящем устройстве сохраняется 2D. -Ограничения: до 2048 файлов, 64 МиБ на исходный файл, 512 МиБ суммарной загрузки и 128 МиБ Float32-вокселей. Это лимит массива объёма, а не всей памяти браузера: сборка и GPU требуют дополнительной памяти. Файлы читаются последовательно только после нажатия кнопки, загрузку можно отменить. При закрытии удаляются движок, GPU-ресурсы и принадлежащие просмотру записи кеша. +Ограничения: до 2048 файлов, 64 МиБ на исходный файл, 1 ГиБ суммарной загрузки и 1 ГиБ Float32-вокселей. Это лимит массива объёма, а не всей памяти браузера: сборка и GPU требуют дополнительной памяти. Файлы читаются последовательно только после нажатия кнопки, загрузку можно отменить. При закрытии удаляются движок, GPU-ресурсы и принадлежащие просмотру записи кеша. Для приватных файлов используются обычные авторизованные API; для публичных — только API текущей ссылки с её токеном. Публичная ссылка на отдельный файл не запрашивает содержимое его родительской папки. diff --git a/frontend/src/i18n/en.json b/frontend/src/i18n/en.json index d65fef39..cbb4f9b4 100644 --- a/frontend/src/i18n/en.json +++ b/frontend/src/i18n/en.json @@ -346,8 +346,8 @@ }, "documents": { "frame": "Frame", - "window": "Contrast (window width)", - "level": "Brightness (window level)", + "window": "Contrast", + "level": "Brightness", "reset": "Reset", "page": "Page", "zoom": "Zoom", @@ -365,7 +365,7 @@ "open3d": "Open as 3D", "back2d": "Back to 2D", "loading3d": "Loading series: {count} / {total}", - "volumeLimit": "This series exceeds the safe 3D preview limit (128 MiB of decoded voxels, 2048 files). Use 2D preview.", + "volumeLimit": "This series exceeds the safe 3D preview limit (1 GiB of decoded voxels, 2048 files). Use 2D preview.", "volumeInvalid": "Cannot build a volume: the slices must belong to one study and series, have matching geometry and uniform spacing. 2D preview remains available.", "volumeUnavailable": "3D preview is unavailable on this device. WebGL2 with volume rendering support is required.", "axial": "Axial", diff --git a/frontend/src/i18n/ru.json b/frontend/src/i18n/ru.json index 68ecf0c4..d5d83737 100644 --- a/frontend/src/i18n/ru.json +++ b/frontend/src/i18n/ru.json @@ -343,8 +343,8 @@ }, "documents": { "frame": "Кадр", - "window": "Контраст (ширина окна)", - "level": "Яркость (уровень окна)", + "window": "Контраст", + "level": "Яркость", "reset": "Сбросить", "page": "Страница", "zoom": "Масштаб", @@ -362,7 +362,7 @@ "open3d": "Открыть как 3D", "back2d": "Вернуться к 2D", "loading3d": "Загрузка серии: {count} / {total}", - "volumeLimit": "Серия превышает безопасный лимит 3D-просмотра (128 МиБ декодированных вокселей, 2048 файлов). Используйте 2D.", + "volumeLimit": "Серия превышает безопасный лимит 3D-просмотра (1 ГиБ декодированных вокселей, 2048 файлов). Используйте 2D.", "volumeInvalid": "Не удалось построить объём: нужны срезы одного исследования и серии, с одинаковой геометрией и равномерным шагом. Просмотр в 2D доступен.", "volumeUnavailable": "3D-просмотр недоступен на этом устройстве. Нужна поддержка WebGL2 и объёмного рендеринга.", "axial": "Аксиально", diff --git a/frontend/src/utils/__tests__/dicom-series.test.ts b/frontend/src/utils/__tests__/dicom-series.test.ts index 08cd23a7..9d5cf905 100644 --- a/frontend/src/utils/__tests__/dicom-series.test.ts +++ b/frontend/src/utils/__tests__/dicom-series.test.ts @@ -87,13 +87,15 @@ describe("DICOM series", () => { ); }); it("rejects excessive allocations before allocating a volume", () => { - expect(MAX_VOLUME_BYTES).toBe(128 * 1024 * 1024); + expect(MAX_VOLUME_BYTES).toBe(1024 * 1024 * 1024); expect(() => - assembleVolume([ - { ...slice(0), rows: 4096, cols: 4096 }, - { ...slice(1), rows: 4096, cols: 4096 }, - { ...slice(2), rows: 4096, cols: 4096 }, - ]) + assembleVolume( + Array.from({ length: 17 }, (_, i) => ({ + ...slice(i), + rows: 4096, + cols: 4096, + })) + ) ).toThrow("DICOM_VOLUME_LIMIT"); }); it("decodes real DICOM slices and validates their geometry", async () => { diff --git a/frontend/src/utils/dicom-series.ts b/frontend/src/utils/dicom-series.ts index dc77bf19..3faa95c1 100644 --- a/frontend/src/utils/dicom-series.ts +++ b/frontend/src/utils/dicom-series.ts @@ -4,7 +4,7 @@ export interface DicomSource { size: number; isDir?: boolean; } -export const MAX_VOLUME_BYTES = 128 * 1024 * 1024; +export const MAX_VOLUME_BYTES = 1024 * 1024 * 1024; export const MAX_SERIES_FILES = 2048; // Names only trigger the offer. Patient-space geometry is checked after consent. diff --git a/frontend/src/utils/dicom-volume.ts b/frontend/src/utils/dicom-volume.ts index 55e25767..30d25c82 100644 --- a/frontend/src/utils/dicom-volume.ts +++ b/frontend/src/utils/dicom-volume.ts @@ -18,7 +18,7 @@ export async function loadDicomVolume( throw new Error("DICOM_VOLUME_LIMIT"); if ( sources.some((s) => s.size > 64 * 1024 * 1024) || - sources.reduce((n, s) => n + s.size, 0) > 512 * 1024 * 1024 + sources.reduce((n, s) => n + s.size, 0) > MAX_VOLUME_BYTES ) throw new Error("DICOM_VOLUME_LIMIT"); const worker = new DicomWorker(); @@ -30,7 +30,7 @@ export async function loadDicomVolume( const buffer = await readDicomFile(source.source, signal); if (signal.aborted) throw new DOMException("Aborted", "AbortError"); bytes += buffer.byteLength; - if (bytes > 512 * 1024 * 1024) throw new Error("DICOM_VOLUME_LIMIT"); + if (bytes > MAX_VOLUME_BYTES) throw new Error("DICOM_VOLUME_LIMIT"); const slice = await new Promise((resolve, reject) => { const cleanup = () => { clearTimeout(timeout); diff --git a/scripts/build-release.ps1 b/scripts/build-release.ps1 index dc870ede..f6cb56c1 100644 --- a/scripts/build-release.ps1 +++ b/scripts/build-release.ps1 @@ -1,4 +1,4 @@ -param([string]$Version = '3.0.0-sso.26') +param([string]$Version = '3.0.0-sso.27') $ErrorActionPreference = 'Stop' $repo = (Resolve-Path (Join-Path $PSScriptRoot '..')).Path Push-Location $repo diff --git a/scripts/build-release.sh b/scripts/build-release.sh index 2d89fc2f..ae6e502c 100644 --- a/scripts/build-release.sh +++ b/scripts/build-release.sh @@ -1,7 +1,7 @@ #!/bin/sh set -eu cd "$(dirname "$0")/.." -VERSION="${VERSION:-3.0.0-sso.26}" +VERSION="${VERSION:-3.0.0-sso.27}" COMMIT=$(git rev-parse --short HEAD) (cd frontend && pnpm install --frozen-lockfile && pnpm run build) mkdir -p build/release/linux-amd64