I have been working on a document generation method and was getting reports that after switching from Xamarin to MAUI, we started to experience the document takes sometimes twice as long as usual to generate.
I was tasked with deep diving into it to find what was going on and I found that there is a call that takes over a second to complete it is almost a single point of bottleneck besides the save call.
[Instrumentation] BuildAcknowledgeTable START: 2025-09-29T19:53:38.4298440-04:00
[Instrumentation] BuildAcknowledgeTable StartTable: 0 ms (+0 ms)
[Instrumentation] BuildAcknowledgeTable Set font bold/size: 0 ms (+0 ms)
[Instrumentation] BuildAcknowledgeTable First cell setup (non-CA): 0 ms (+0 ms)
[Instrumentation] BuildAcknowledgeTable WritelnSafe blanks 1: 0 ms (+0 ms)
[Instrumentation] BuildAcknowledgeTable InsertShape initialsLine1: 1064 ms (+1064 ms)
[Instrumentation] BuildAcknowledgeTable WritelnSafe blank 2: 1064 ms (+0 ms)
[Instrumentation] BuildAcknowledgeTable WriteSafe General_Initials 1: 1064 ms (+0 ms)
[Instrumentation] BuildAcknowledgeTable Second cell setup (non-CA): 1064 ms (+0 ms)
[Instrumentation] BuildAcknowledgeTable Write AVL acknowledge text and hyperlinks: 1065 ms (+1 ms)
[Instrumentation] BuildAcknowledgeTable WriteSafe period 1: 1065 ms (+0 ms)
[Instrumentation] BuildAcknowledgeTable EndRow 1: 1065 ms (+0 ms)
[Instrumentation] BuildAcknowledgeTable First cell setup (main block): 1065 ms (+0 ms)
[Instrumentation] BuildAcknowledgeTable Set font bold 2: 1065 ms (+0 ms)
[Instrumentation] BuildAcknowledgeTable WritelnSafe blanks 2: 1066 ms (+1 ms)
[Instrumentation] BuildAcknowledgeTable InsertShape initialsLine2: 1066 ms (+0 ms)
[Instrumentation] BuildAcknowledgeTable WritelnSafe blank 3: 1066 ms (+0 ms)
[Instrumentation] BuildAcknowledgeTable WriteSafe General_Initials 2: 1066 ms (+0 ms)
[Instrumentation] BuildAcknowledgeTable Second cell setup (main block): 1066 ms (+0 ms)
[Instrumentation] BuildAcknowledgeTable Set acknowledgeText and urlText for AVL: 1067 ms (+1 ms)
[Instrumentation] BuildAcknowledgeTable WriteSafe acknowledgeText and hyperlink: 1067 ms (+0 ms)
[Instrumentation] BuildAcknowledgeTable EndRow 2: 1067 ms (+0 ms)
[Instrumentation] BuildAcknowledgeTable EndTable: 1067 ms (+0 ms)
[Instrumentation] BuildAcknowledgeTable END: 2025-09-29T19:53:39.4974810-04:00 | Elapsed: 1067 ms
The InsertShape call that is causing this is:
var initialsLine1 = builder.InsertShape(ShapeType.Line, RelativeHorizontalPosition.Character, 0, RelativeVerticalPosition.Paragraph, 0, 20, 0, WrapType.Inline);
I can’t understand why it would have such a big performance hit.
I can provide any additional information needed here, but I was curious if there is any pitfalls that I may need to consider if if this may be a bug with the DocumentBuilder