none
Performance issues with application level add-in in word 2013 RRS feed

  • Question

  • Hi,

    I’m working on an application level addin(with ribbon controls) for word 2013 and we have some performance issues.

    The performance issue is when we create a new document or open an existing document.

    Our addin is designed to have its own tab with a bunch of controls that does different things to the active document.

    There are a couple of things that needs to run during initialization of our addin in order to populate some of the

    controls. We are in fact making 3 calls to a rest service during startup among a couple of other small things.

    If i take theses 3 calls out i can see a performance increase but it still takes a lot of time before word shows the document

    to the user.

    If a make a comparison:

    1. Open up a document without the addin from the user desktop takes about 1-2 seconds
    2. Open up a document with the addin takes about 5-6 seconds.
    3. Open up a document with the addin(taken the 3 calls to the service out) takes 4-5 seconds.
    4. According to the following article http://msdn.microsoft.com/en-us/library/bb386106.aspx we can
      adjust the LoadBehaviour. I have set its value to 16. Opens up the document the first time(5-6 seconds).
      The second time I open up the document it takes about 2-3 seconds. 2-3 seconds is acceptable performance.

      However, since the addin is now loaded on demand a couple of things that are supposed to run during
      initialization runs only when the user interacts with any user control within our addin. Are there perhaps
      some other event that I can listen to in order to initialize the ribbon controls and processing of the open document?

    I realize this is not much to go on but are there any other performance optimizations that can be done?

    Br,

    /Peter


    Peter

    Friday, May 30, 2014 10:59 AM

Answers

  • Hi Eugene,

    Instead of using Word.Application.Documents.Open method i used Process.Start. Much faster!
    Almost as fast as no addin was installed. :)

    However, it gives me less control over the word instance. So, i will for example not be able
    to control whether or not the document is opened maximized.

    I checked for available switches that word excepts but it does not seem to be any switch
    that maximizes the window.

    Br,
    /Peter


    Peter

    Monday, June 2, 2014 2:32 PM

All replies

  • Hello Peter,

    You need to run secondary threads for calling the web services. Also I would recommend to logging operations in the add-in and find a week property or method calls.

    Did you have a chance to test a newly created clean add-in project? Do you get any delay in that case?

    Is the Check for publisher's certificate revocation setting enabled on the problematic PC?

    Friday, May 30, 2014 3:49 PM
  • Hi,

    Thanks for the quick reply!

    I did implement secondary threads for calling the service. However, it still takes a lot of time to load the add-in.

    I also implemented logging so i do log every exception that arrises. So, i have been able to trap som exceptions

    that i will fix but i do not think that they are the cause of our performance issues.

    I have not tried to build another clean project, why do you think this would help? Is it that my current project

    might be corrupted in some way?

    I have not checked the Check for publisher's certificate revocation setting but that will be my first action.

    Br,

    /Peter


    Peter

    Monday, June 2, 2014 8:13 AM
  • Hi again,

    I have tested the performance after unchecking the Check for publisher's certificate revocation  in internet explorer advanced settings.
    No change in performance.

    I know that i have tested this before but i commented out almost everything within the addin that could impact performance and it still takes about 4-5 seconds to load the add-in.
    After that i did a build clean on the project to unload the addin. I now takes about 1-2 seconds to load the document.
    So, something is going on. I will try to create a new project and get back to you.

    Br,
    Peter


    Peter

    Monday, June 2, 2014 9:41 AM
  • Hi,

    I have now created a new Word 2013 addin project to which i also added a Ribbon xml item.
    I modified the project so that it has one ribbon button with a callback function which shows a Message box
    when the user clicks the button.

    With the addin installed it takes about 4-5 seconds to open up a document. If i uninstall the addin it takes about 1-2 second
    to open up the document.

    One other observation is that if i open up an existing document from disc it opens up really quick(1-2 seconds).
    So, that seems to work fine.

    When i earlier was talking about open up a document takes 4-5 seconds we are actually
    open up the document from within another system so it might be that we are using some old
    technique when we are opening the document which i'm thinking impacts the performance when
    loading the addin. Perhaps there are some switches or alike that needs to be specified when
    opening the document programmatically?

    Here is how we are opening up an existing document.

    wordApp = New Word.Application()
    wordApp.Documents.Open(FileName:=pFileName, Format:=Word.WdOpenFormat.wdOpenFormatXMLDocumentMacroEnabled)

    So, just to be clear. It takes 1-2 seconds to open up a document programmatically without a addin installed.
    When even the simplest addin is installed it takes about 4-5 seconds to open up the document.

    Any ideas? :)

    Br,

    /Peter


    Peter

    Monday, June 2, 2014 12:09 PM
  • Peter,

    I hope you don't use the code in a COM add-in:

    wordApp = New Word.Application()
    wordApp.Documents.Open(FileName:=pFileName, Format:=Word.WdOpenFormat.wdOpenFormatXMLDocumentMacroEnabled)

    Did you try to omit the Format parameter? What is the actual value (pFileName) passed to the Open method?

    Finally, you can try using the NGEN utility.

    Monday, June 2, 2014 12:21 PM
  • Hi,

    No, this code is used within a windows application.
    I did try to omit the Format parameter but it gives me the same result.

    The actual value of pFileName is the path to the document to be opened.
    For example: C:\Users\XPPro1\AppData\Local\Temp\3_0_0\myDocument.docm

    Is it normal to be forced to use NGEN for performance reasons?

    Br,
    Peter


    Peter


    Monday, June 2, 2014 12:32 PM
  • Peter,

    Ngen may improve the performance of jitter because the assembly shouldn't be translated to machine code in that case.

    Did you experiment with *.doc or *.docx files? Do you get the same results?

    Monday, June 2, 2014 12:37 PM
  • Hi Eugene,

    Yes, i have played around with different formats but still the same result.

    I just can't help wondering where the different lies when you open up a document
    from the desktop it works fine but when opening the document programmatically
    it gives an overhead with several seconds. Could it be that word uses some other technique?

    Br,
    /Peter


    Peter

    Monday, June 2, 2014 12:52 PM
  • Hi Peter

    <<When i earlier was talking about open up a document takes 4-5 seconds we are actually open up the document from within another system >>

    Calls will always be slower when code is 1) running; 2) running out-of-process (as opposed to native VBA); and 3) when security considerations ("another system") might be kicking in. Using Documents.Open will ALWAYS be slower than when the user opens a document.

    <<I did implement secondary threads for calling the service. However, it still takes a lot of time to load the add-in.>>

    Loading the add-in and loading a document are two separate things. Or is the issue that Word isn't already running when the user wants to open a document, so the two actions are summing up the time until the user sees the document?


    Cindy Meister, VSTO/Word MVP, my blog

    Monday, June 2, 2014 2:27 PM
    Moderator
  • Hi Eugene,

    Instead of using Word.Application.Documents.Open method i used Process.Start. Much faster!
    Almost as fast as no addin was installed. :)

    However, it gives me less control over the word instance. So, i will for example not be able
    to control whether or not the document is opened maximized.

    I checked for available switches that word excepts but it does not seem to be any switch
    that maximizes the window.

    Br,
    /Peter


    Peter

    Monday, June 2, 2014 2:32 PM
  • Hi Peter

    GetActiveObject can pick up the existing process...


    Cindy Meister, VSTO/Word MVP, my blog

    Monday, June 2, 2014 2:48 PM
    Moderator
  • Hi,

    I found a way to maximize the window with Process.Start also so i think we have found a way =D
    Thank you for your time on this!
    If you have any thoughts please feel free to share them with me :)

    Br,
    /Peter


    Peter

    Monday, June 2, 2014 2:51 PM
  • Thanks Cindy! I will keep that in mind :)

    Peter

    Monday, June 2, 2014 2:59 PM