[okular] [Bug 507802] Opening / Loading PDF from Samba share (SMB / CIFS) is very slow

Sebastian bugzilla_noreply at kde.org
Sun Nov 9 22:13:05 GMT 2025


https://bugs.kde.org/show_bug.cgi?id=507802

--- Comment #5 from Sebastian <sebastian_steiner at gmx.de> ---
Hi, I hope I have solved the problem: 

When loading files from a network share, Poppler is very slow as it iterates
over the file in small chunks which causes a lot of network round trips. 

I changed PDFGenerator::loadDocumentWithPassword in Okular's generator_pdf.cpp
like this:

// BEGIN Generator inherited functions
Okular::Document::OpenResult PDFGenerator::loadDocumentWithPassword(const
QString &filePath, QVector<Okular::Page *> &pagesVector, const QString
&password)
{
#ifndef NDEBUG
    if (pdfdoc) {
        qCDebug(OkularPdfDebug) << "PDFGenerator: multiple calls to
loadDocument. Check it.";
        return Okular::Document::OpenError;
    }
#endif
    QFile file(filePath);
    if( !file.open(QIODevice::ReadOnly) ) {
        // Error: File not readable.
        return Okular::Document::OpenError;
    }
    QByteArray fileContent = file.readAll();
    // create PDFDoc for the given file
    pdfdoc = Poppler::Document::loadFromData(fileContent, nullptr, nullptr);
...

This should load the entire fill into a QByteArray at once and then pass this
in-memory QByteArray buffer to Poppler. 

With this change, Okular seems to display PDF files from network shares faster
by factor >100 I guess. :D Amazing! 

Could you maybe implement the change in Okular? <3

I guess it might be reasonable to implement some limit for this in-memory
loading, e.g. allow to take up to 20% of system memory available and otherwise
fall back to the current approach?

While opening a PDF file of 2,4 MB from a Samba share could take almost an hour
before the change, it now opens within seconds! :D 
And nowadays, it should be no problem to load 2,4 MB into memory.

-- 
You are receiving this mail because:
You are the assignee for the bug.


More information about the Okular-devel mailing list