Closed charlesoconor closed 10 months ago
Sorry, without a reproducible example, I don't even know what this is supposed to fix if it works, and what it does. It adds a lot of complexity, and for now, without known reason. My impression was that anything MuPDF thread-related is only for displaying PDFs.
Understood. I'll try to find something I can share and report back but closing for now.
They recommend creating a root context for applications running concurrently. This should allow for caching fonts and layers across runs. I was also dealing with segfaults out of mupdf when creating images in a threaded server since there were some shared objects the library creates that weren't safe to access.
Problems with this solution:
A reliance on
pthread
which isn't supported on all platforms.It's creating c locks which may not play nicely with go routes. I've been running with this patch applied in my service and haven't noticed any problems.
Might leak memory over time since there isn't currently a way to clean the root context.
I was looking to see if it makes sense to clean up and upstream or if the problems seem to big. Could update the build to link in the concurrency only on Unix system.
Repo to get this to happen a lot of the time with documents that share things across pages. Unfortunately I can't share the pdf we found that did this consistently.