Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
0

Out of memory exception when calling addAnnotations

Community Beginner ,
Mar 04, 2025 Mar 04, 2025

Hi all. I work on an application that applies annotations to PDF documents.

 

After loading the PDF viewer we call the annotation manager API's addAnnotations method. The promise eventually errors out with the following error (see image below) "Error: std::bad_alloc,std::bad_alloc", and we can see that some of the annotations have not been added.

 

Some important context is that we are attempted to add up to 500 different annotations to a given PDF. From my (admittedly basic) tests, the limit appears to be around 120 annotations before the error happens.

 

I have attached an image of the browser's console. This is in Google Chrome.

 

Screenshot 2025-03-04 at 21.17.57.pngexpand image

 

Is there a known maximum number of annotations that is supported? I did not see a number mentioned in the docs. 

 

I tried chaining the addAnnotation promises in batches of 100 at a time, but the error still occured.

 

Very interested to hear if anyone has also had this same issue, or if any Adobe devs would like to take a look that would be excellent and greatly appreciated.

 

Thanks for reading.

TOPICS
Bug , PDF Embed API
244
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Mar 10, 2025 Mar 10, 2025

You'd listen for the CURRENT_ACTIVE_PAGE event.

Translate
Community Beginner ,
Mar 06, 2025 Mar 06, 2025

I wanted to also attach a copy of the adobe log message that was being sent in the network event:

 

[
 {
   "level":"error",
   "message":"Reached maximum number of initial events",
   "sessionId":"ba2ede6a-5049-4d09-b823-7a61c1b9fd77",
   "viewSDKAppVersion":"3.27.1_3.2.10-ea8924cb",
   "tenantId":"--private--",
   "callingApp":"dc-view-sdk",
   "externalUserId":"--private--",
   "clientId":"--private",
   "client_timestamp":"2025-03-06T14:13:53.240Z",
   "context":"Analytics"
 }
]
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 06, 2025 Mar 06, 2025

Try adding them in batches of 10.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Mar 06, 2025 Mar 06, 2025
quote

Try adding them in batches of 10.


By Joel Geraci

 

Hi Joel, thanks for your reply. Batches of 10 unfortunately ends up in the same result. I've attached my console log, after each promise resolved I printed the batch index. I also tried batches of 5, and despite getting a little further this time, still ends up failing.

 

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Mar 06, 2025 Mar 06, 2025

Further to add, even running one at a time I am unable to get even to 200 annotations added. Strangely batches of 5 seems to get the furthest at around ~200 annotations.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 06, 2025 Mar 06, 2025

I'm guessing there are just too many updates that are trying to redraw the PDF for Embed to handle. I'm going to suggest something a bit unorthodox. Try adding only the annotations that are for the currently viewed page, listen to the page change event (whatever that's called) and then add the annotations for that page. 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Mar 10, 2025 Mar 10, 2025

Hi Joel, I had been thinking along a similar line, however from reading the docs I didn't see an event regarding a page change. Could you point me in the direction?

 

In our application the user can either interact with a non-adobe component, and this can navigate to a page using the `gotoLocation` method on the viewer API. But obviously they can also interact with the Adobe client itself, which we don't have any awareness of currently.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 10, 2025 Mar 10, 2025

You'd listen for the CURRENT_ACTIVE_PAGE event.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Mar 11, 2025 Mar 11, 2025

Thank you Joel, this has worked perfectly. I really appreciate your help!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 11, 2025 Mar 11, 2025
LATEST

Yeah. I was guessing that the redraw buffer was getting over run. Glad you have a solution.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources