OfficeDev / office-js

A repo and NPM package for Office.js, corresponding to a copy of what gets published to the official "evergreen" Office.js CDN, at https://appsforoffice.microsoft.com/lib/1/hosted/office.js.
https://learn.microsoft.com/javascript/api/overview
Other
657 stars 93 forks source link

Add-In Size Limit for CustomXMLPart on Web #2408

Closed kodefile closed 3 months ago

kodefile commented 2 years ago

Message from office-js bot: We’re closing this issue because it has been inactive for a long time. We’re doing this to keep the issues list manageable and useful for everyone. If this issue is still relevant for you, please create a new issue. Thank you for your understanding and continued feedback.

Provide required information needed to triage your issue

I have written an add-in for Word that stores some data as a custom xml part. When the add-in runs on the Desktop for both Windows 11 and MacOS, I can insert custom xml parts larger than 7MB. However, when the same add-in runs on the web (I have tested this for Edge, Chrome and Firefox on Windows 11), I am unable to add any custom XML part where the XML String is larger than precisely 1MB . Office.context.document.customXmlParts.addAsync returns an error code 6100 with the message Custom XML Error for anything larger than 1MB.

Your Environment

Expected behavior

When inserting a Custom XML Part that is larger than 1MB, I expected Office.context.document.customXmlParts.addAsync to return a Office.AsyncResult result object with the value = CustomXMLPart that was added. This is the case with the Add-in on Word on Desktop (Windows 11)

Current behavior

When inserting a Custom XML Part that is larger than 1MB, Office.context.document.customXmlParts.addAsync returns a Office.AsyncResult result object with an error with code 6100 and message CustomXML Error

This inconsistency between the Desktop version and the Web Version makes it difficult to create a plugin that will offer consistent behavior and functionality across platforms. Is there any reason this limit exists for the Web Version but NOT the Desktop version?

Steps to reproduce

  1. __Create an XML String of total length 1MB + 1 byte (1,048,577 bytes)
  2. __attempt to insert the xml string as a custom xml part using Office.context.document.customXmlParts.addAsync
  3. _addSync returns a result object containing an error with code: 6100 and message: Custom XML Error

Link to live example(s)

  1. Office on the Web scriplab snippet
  2. To demonstrate the problem, load the script and click "Run Snippet", see the console logged output.
  3. The console output will show successful addition of the custom xml part for 1,048,568 - 1048576 bytes and fails attempting to add 1048577
  4. The script below when run on Desktop shows that the Custom XML Part that can be added is significantly higher than the 1MB on the Web. The script adds XML String of size 1MB and shows that the custom xml part can be addes successfully with increments of 1MB up to a total size of 10MB (limited for purposes of demonstration)
  5. Office Desktop scriptlab snippet

Context

This issue prevents us from developing an add-in where data can be stored in custom xml parts consistently across platforms.

RuizhiSunMS commented 2 years ago

Thank you for reporting this issue. The limitation towards file size is by designed according to consideration on server's load and others. So we will not fix it in short term. We recommend you to submit a new Tech Community New Ideas Item which will give us visibility of the commonality of it (You can submit on https://aka.ms/m365dev-suggestions).

kodefile commented 2 years ago

Thank you for reporting this issue. The limitation towards file size is by designed according to consideration on server's load and others. So we will not fix it in short term. We recommend you to submit a new Tech Community New Ideas Item which will give us visibility of the commonality of it (You can submit on https://aka.ms/m365dev-suggestions).

Thanks for your feedback on this issue but I am not sure I understand the issue about server load because I can add multiple CustomXML Parts each of size 1MB. I have successfully added 27 CustomXML Parts, each 1MB, in a single file. So the aggregate size of the custom xml is 27MBs. The CustomXML Part size limitation wouldn't be an effective way of limiting server loads.

The Size Limit on the Web create a more significant problem as described below:

If I use Office on the Desktop and add a large (> 1MB) customxml part and save the document, I can then open the document using Office on the Web without any errors. However, when I attempt to read the customxml part on Office on the Web, the application returns an error indicating that the CustomXML Part was NOT FOUND.

This error is indistinguishable from a case where the CustomXML Part is actually missing and there is no way to disambiguate the errors. In addition, Office on the Web and Office on the Desktop should allow opening and accessing parts of the file in a consistent manner regardless of what platform they were created on (desktop or web). So I can understand limiting ADDING CustomXML Part for Office on the Web to 1MB but READING the CustomXML Part should NOT be subject to the same limitation. If this limitation must be present, then an unambiguous error message should be returned.

I would appreciate your thoughts on this issue and look forward to hearing from you.

Thank you.

xiruatms commented 2 years ago

@kodefile , thanks a lot for your feedback. All of your findings and insights mean a lot to us.

Given some existing limitation and consideration, the current implementation might not be the best option. A serious discussion had been held between related teams. A work item 5794915 is now logged. The priority and/or efforts will be evaluated and planned along with other work items. This might not be resolved in a short time, but I'm sure it will be carefully tracked.

One more to confirm with you:
How did you get the following error? "the application returns an error indicating that the CustomXML Part was NOT FOUND."

Thanks again. Your help are greatly appreciated.

kodefile commented 2 years ago

Greatly appreciate you looking into this issue. To get the error referenced above, I used Word on Desktop to add a CustomXML part that was 2MB to a document and saved it. I then used Word on the Web to open the document and attempted to retrieve the custom xml part using Office.context.document.customXmlParts.getByIdAsync(id, callback). This method returned an Office.AsyncResult object containing an error indicating that the Custom XML Part was not found. Specifically, the error object contains: Error Code: 6000 Error Name: Invalid Node Error Message: The specified node was not found.

To demonstrate this problem, I have created 2 scripts.

Demo docx CustomXMLDemo.docx. This file contains a single custom xml part (2MB) which was added using the first script mentioned above.

If you open the file on Word on Desktop and run the second script to read the custom xml part, you will get a message indicating that the custom xml part was retrieved successfully as illustrated in this screenshot

word_desktop

If you open the file on Word on the Web and use the second script to attempt to get the custom xml part. This will print out the error message on the console.

word_web

NOTE: I have hard-coded the Custom XML Part ID in the script for simplicity. Make sure to update it if you edit/recreate the custom xml part.