diff --git a/src/core/document.js b/src/core/document.js index 434cbac2a6325..25952d0016979 100644 --- a/src/core/document.js +++ b/src/core/document.js @@ -707,7 +707,7 @@ class Page { const structTree = await this.pdfManager.ensure(this, "_parseStructTree", [ structTreeRoot, ]); - return structTree.serializable; + return this.pdfManager.ensure(structTree, "serializable"); } /** diff --git a/web/struct_tree_layer_builder.js b/web/struct_tree_layer_builder.js index ead85bbf12507..72ba6bc5c111c 100644 --- a/web/struct_tree_layer_builder.js +++ b/web/struct_tree_layer_builder.js @@ -112,8 +112,14 @@ class StructTreeLayerBuilder { } async getAriaAttributes(annotationId) { - await this.render(); - return this.#elementAttributes.get(annotationId); + try { + await this.render(); + return this.#elementAttributes.get(annotationId); + } catch { + // If the structTree cannot be fetched, parsed, and/or rendered, + // ensure that e.g. the AnnotationLayer won't break completely. + } + return null; } hide() {