WE have a site where the Adobe Embed API has been working well for months, but in the last week started popping up with the error PREVIEW_RENDERING_FAILED, which fails to even show an error message, instead we get a completely blank screen, this is intermittent, sometimes it will show the PDF fine, other times it seems to timeout the promise.
The files are loaded from an API and using a fileReader we are creating an ArrayBuffer, which has not changed in any way, and the files sometimes load and then sometimes we receive a blank screen and the PREVIEW_RENDERING_FAILED error. The files are not large, max is currently around 2MB and the only way I can consistently show the error is if I 3G throttle the connection, just seems to time out even with small files, but it is intermittent even on a non throttled connection, it is as if the promise resolution even though the file has been received is timing out.
The error seems to be thrown in ViewSDKInterfaceApp.js on the line which gets the exposed APIs but that could just be the browser interpretation, its the last place on the stack trace, which shows:
previewFile(fileInfo, previewConfig) {
this._logExternal("Starting process to preview file.", fileInfo.metaData, previewConfig);
return this._embedModeHandlerService
.initialiseAction(fileInfo, previewConfig, IFrameMessageTypes.PREVIEW, hostAppStartTime)
.then(() => this._adobeViewer.getExposedAPIs({ previewConfig }));
}
There are also some XHR requests going to https://dc-api.adobe.io/system/log which seem to have some additional information:
{
"level": "error",
"message": "Error in preview, file rendering timeout",
"sessionId": "41188030-6b8f-47f9-9ab2-3b6dca66d104",
"viewSDKAppVersion": "REDACTED",
"tenantId": "REDACTED",
"callingApp": "dc-view-sdk",
"externalUserId": "REDACTED",,
"clientId": "REDACTED",
"client_timestamp": "2023-08-22T19:45:58.200Z",
"context": "AppStore"
}
And
{
"level": "error",
"message": "File preview blocked as preview failed to load REDACTED",
"sessionId": "REDACTED",
"viewSDKAppVersion": "3.2.4_3.2.0-bab76ff9",
"tenantId": "REDACTED",
"callingApp": "dc-view-sdk",
"externalUserId": "REDACTED",
"clientId": "REDACTED",
"client_timestamp": "2023-08-22T19:45:58.253Z",
"context": "App"
}
Our code is pretty standard I think based on the official documentation when dealing with a non url file, in our case from an API endpoint. the code has been working for months, its just started to happen this with no changes to the way this has been working.
Our fetch code looks like:
const fetchPDF = (id: string, title: string, pages: number) => {
fetch(`/api/pdf/${id}`)
.then((response) => response.blob())
.then((blob) => {
const reader = new FileReader();
reader.onloadend = (e) => {
const filePromise = Promise.resolve(e.target?.result)
previewPDF(filePromise, title, pages)
}
reader.readAsArrayBuffer(blob)
})
}
previewPDF function:
const previewPDF = (filePromise: any, title: string, pages: number) => {
const adobeDCView = new AdobeDC.View({
clientId: config.adobeApiKey,
divId: `adobe-dc-view-${props.id}`,
})
adobeDCView.previewFile(
{
content: {
promise: filePromise,
},
metaData: { fileName: title },
},
{
embedMode:
props.mode.toLowerCase() === 'lightbox' ? 'LIGHT_BOX' : 'IN_LINE',
exitPDFViewerType:
props.mode.toLowerCase() === 'lightbox' ? 'CLOSE' : 'RETURN',
showPrintPDF: true,
defaultViewMode: pages > 1 ? 'FIT_PAGE' : 'FIT_WIDTH',
}
)
}