Getting an Uncaught RuntimeError: memory access out of bounds exception when opening another PDF in the WebViewer

PDFTron Webviewer
Product Version:

Please give a brief summary of your issue:
Uncaught RuntimeError: memory access out of bounds when opening a PDF in web viewer

Please describe your issue and provide steps to reproduce it:
(The more descriptive your answer, the faster we are able to help you)
The issue has come up after we implemented preloading to try and make the web viewer a little faster in our Angular application. The issue is caused when a previous PDF hasn’t been closed, and attempting to open a new one causes the memory out of access exception.

I’ve tried calling the .close() functions as well as the .dispose() functions before and after a document has been loaded, and the issue still seems to persist. Is there a reason why these two functions wouldn’t close the previous PDF that has been opened?

Any help on this is greatly appreciated!

Hi @mohammad.mansoor,

How are you pre-loading the viewer? Have you had a chance to go over our guide on this?

If you are hiding the element with display: none this may cause issues:

Don’t use “display: none” to hide the element
This causes issues with iframes and web workers. Use “visibility: hidden” or “height: 0; width: 0;” instead.
You may see an error like “memory access out of bounds”, NS_ERROR_FAILURE or “getComputedStyle(…) is null”

Best Regards,
Armando Bollain
Software Developer
PDFTron Systems, Inc.

Yes, we followed the guide when implementing the preloading and also avoided using display: none; when hiding the WebViewer between documents. It seems like the previous document hasn’t closed properly, so when a new one is added the browser runs out of memory, even after explicitly calling the functions to do so.

Also, this seems to only be occuring on Chrome. When running the WebViewer in Firefox I run into no memory issues.

Hello @mohammad.mansoor,

Since this is only happening in Chrome, would it be possible for you to try forcing the backendType to be ems?

The backendType can be passed as a WebViewer initialization option:

This is to rule out any potential issues with WASM-threads. Also please ensure you are on the latest version of Chrome.

If this does not resolve the issue, can you create a sample project where we are able to reproduce this issue?

Best Regards,
Armando Bollain
Software Developer
PDFTron Systems, Inc.