AL icon indicating copy to clipboard operation
AL copied to clipboard

Error publishing app with large XMLPort (2435(!) nodes)

Open MicAlter31 opened this issue 7 years ago • 6 comments

Describe the bug In our v1 Extension we use a large XML-Port with 2435 nodes. The XMLPort can be converted correctly to AL and also the build process is successful. But when publishing the app in a Business Central Sandbox environment the process will fail with error "Insufficent stack to continue executing the program safely. This can happen from having too many functions on the call stack or function on the stack using too much stack space."

To Reproduce Steps and/or AL code to reproduce the behavior:

  1. Create a large XML-Port with 2435 nodes
  2. Build and publish the app

Expected behavior The app can be published successfully.

Screenshots 20190107 error large xmlport

Versions:

  • AL Language: 2.1.69331
  • Business Central: 13.0.26198.0

MicAlter31 avatar Jan 07 '19 16:01 MicAlter31

@MicAlter31 can you refactor this XMLPort? This is an exceptionally large object and it pushes the boundaries on what can be done with our compiler and the underlying infrastructure.

atoader avatar Jan 07 '19 20:01 atoader

We had the same Issue and removed the XMLPort. Changed to Codeunit with XmlDocument, XmlNodeList,XmlNode and so on..

Works like a charm 😃

dNsl9r avatar Jan 08 '19 06:01 dNsl9r

@atoader We had a look at the code. The main problem is a huge data section with a lot of nodes (20k lines of code). Inside the OnAfterAssignVariable-Trigger of this section the most of all nodes were processed. You can imagine that this transformation will consume a lot of time. I am missing the specifications and limitations for XMLPorts in the Microsoft Docs (Link). Can you tell me how many nodes can be used at the maximum?

@dNsl9r In most cases we have already converted the code accordingly. In this case, we first wanted to convert our old code to do the refactoring afterwards.

MicAlter31 avatar Jan 08 '19 09:01 MicAlter31

@MicAlter31 I fully understand, we wanted to do the same. I support the idea of adding the information of how many nodes can be used max for XMLPorts in .al

dNsl9r avatar Jan 08 '19 09:01 dNsl9r

@MicAlter31 The maximum number of nodes depends on many factors, as the compiler transforms it into the recursive calls, which results in insufficient stack exception. Our rough estimation is around 750-820 steps, i.e. nested nodes.

AndreyKorepanov avatar Jan 28 '19 13:01 AndreyKorepanov

Hello @AndreyKorepanov , Hello @atoader,

we are having the same error message, when we try to deploy a customized base application. The difference is, that we do not have xmlports with 2k nodes. Does this apply to another object types?

We do have a lot of objects (project has 10k objects) and some codeunits have 9k lines of code. The biggest object is about 800kb. Is there a limit about the amount of objects in an app or a limit how big an object can be? (or number of code lines in an object).

Thanks in advance, Christian;

Using:

  • Business Central 15
  • AL Version 4.0

MAC-Christian avatar Nov 15 '19 13:11 MAC-Christian