Repository navigation
v3.1.0 — Production operations: metrics, back-pressure, warm-up & health checks
EasyOcrSharp 3.1.0 makes the library something you can run, not just call: you can alert on it, bound it, and prove it works before traffic arrives.
Everything is additive — no public type, member or default was removed or changed, and every new guard is off by default. Upgrading changes no behaviour.
dotnet add package EasyOcrSharp --version 3.1.0✨ Added
Metrics you can build an SLO on
easyocr.operations, .duration, .lines and .pages are now tagged with easyocr.operation, easyocr.outcome, easyocr.provider, easyocr.languages and — on failures — error.type, so latency and error rate can be sliced by entry point, language and CPU-vs-GPU. New saturation instruments: easyocr.queue.wait, easyocr.operations.active, easyocr.operations.queued. The constants are public (EasyOcrDiagnostics.TagNames / .Outcomes / .OperationNames), so alert rules need no magic strings.
Concurrency limiting & operation timeouts
new EasyOcrServiceOptions
{
MaxConcurrentOperations = Environment.ProcessorCount, // 0 (default) = unlimited
QueueTimeout = TimeSpan.FromSeconds(30), // then shed with OcrBusyException
OperationTimeout = TimeSpan.FromMinutes(2), // 0 (default) = no cap
}ONNX sessions are thread-safe to share, but every concurrent run allocates its own tensors — so concurrency, not session count, sets peak memory. Past the limit, work waits up to QueueTimeout and is then refused with the new OcrBusyException (503-shaped) rather than queued without bound; a single operation that blows its budget fails with OcrTimeoutException (504-shaped). Both derive EasyOcrSharpException, so existing catch-all handlers keep working.
Warm-up hosted service
services.AddEasyOcrWarmUp("en") loads models off the startup path, so a host that cannot reach the model mirror still starts and reports its state instead of crash-looping. Progress is exposed through EasyOcrWarmUpState.
A health check that proves OCR actually runs
The existing check only verified model files existed — a truncated download, a half-copied cache, or a GPU whose provider fails at session init all reported Healthy and then failed every request. Opt into a deep probe that runs a real page through the pipeline, caches the verdict, and reports the execution provider that actually resolved:
builder.Services.AddHealthChecks()
.AddEasyOcrHealthCheck(new EasyOcrHealthCheckOptions { DeepProbe = true },
languages: ["en"], name: "easyocr-ready");It never triggers a download, and readiness stays not-ready while warm-up is still running.
Instrumented composite paths
PDF, searchable-PDF, multi-frame and batch runs now emit metrics and spans — previously they emitted none at all.
🐛 Fixed
- Metrics were recorded only on the success path, so a deployment failing every request reported zero operations rather than a 100% error rate — the one shape of failure a dashboard cannot see. Failures, cancellations, timeouts and shed load are now all recorded and classified apart, so load shedding under a burst doesn't page anyone as a defect.
EasyOcrDiagnosticsreported version2.2.1on a 3.x package, mislabelling every metric and span it emitted. Now pinned to the csproj by a test.- A timeout ceiling that only failed under load.
SemaphoreSlim.WaitAsync(TimeSpan)does not validate its argument up front — with a permit free it returns on the fast path and never arms a timer. So an over-longQueueTimeoutsurvived every uncontended dev run and CI pass, then threwArgumentOutOfRangeExceptionout of the first request that actually had to queue: the back-pressure path failing precisely when back-pressure existed. The real ceiling isuint.MaxValue - 1ms (~49.7 days), notint.MaxValuems (~24.8 days), andOperationTimeouthad no clamp at all. Both knobs now share one measured ceiling.
📦 Also in this release
The work prepared as 3.0.1 and never published ships here, so 3.0.1 does not exist as a public version:
- Dictionary class-shift in PP-StructureV3 — every document-analysis language pack decoded one character class off (Russian came out as mojibake). Affected Cyrillic, Latin, Arabic, Devanagari, Korean, Japanese, Thai, Greek, Telugu, Tamil and East Slavic packs.
- Non-ASCII JSON output was escaped to
\uXXXX; Cyrillic, Greek, Arabic, Hebrew, CJK and Devanagari now emit verbatim. - Layout NMS and reading order — duplicate regions collapsed, and PP-DocLayoutV3's predicted reading order is now used.
- Right-to-left reading order for Arabic, Persian, Urdu, Uyghur and Hebrew.
- Transparency and EXIF decode fixes — images with alpha decoded to a black page and EXIF-rotated phone photos were read sideways; both returned empty or near-empty text with no error.
Packages
| Package | Version |
|---|---|
EasyOcrSharp |
3.1.0 |
EasyOcrSharp.Cli |
3.1.0 |
EasyOcrSharp.Gpu |
3.1.0 |
Full changelog: https://github.com/FarhanLodi/EasyOcrSharp/blob/main/CHANGELOG.md