IntelliSense icon indicating copy to clipboard operation
IntelliSense copied to clipboard

Excel 365 window become laggy

Open sylvainpiron opened this issue 3 years ago • 3 comments

When I use an intellisense 1.6 Addin with

public void AutoOpen()
{
            ExcelIntegration.RegisterUnhandledExceptionHandler(ex => "!!! ERROR: " + ex.ToString());
            IntelliSenseServer.Install();
}

Excel window become laggy when you move it.

sylvainpiron avatar Nov 22 '22 17:11 sylvainpiron

I have the same issue with ExcelDna.IntelliSense.1.4.2 and Excel 365. After loading an xll that uses the intellisense addin, the Excel window is slow to move around -- it lags the expected mouse movement when dragging the window.

markasam avatar Nov 24 '22 00:11 markasam

I can see the behaviour too - I don't know whether this changed with a recent IntelliSense version or with newer Excel. I had not noticed this before.

govert avatar Nov 24 '22 08:11 govert

I believe this behaviour is not very new in that colleagues of mine who use an addin that I maintain (VBA, with an _IntellisSense_ worksheet) have been complaining of the laggy Excel window for some months. It was only today that we looked into it and discovered that uninstalling Intellisense made the problem go away. We too are using ExcelDna.IntelliSense.1.4.2 and Excel 365.

On some PCs we see the lag for both moving and resizing the Excel window. On other PCs, there's no lag when moving the window but there is when resizing it.

PGS62 avatar Nov 25 '22 13:11 PGS62

Hi, this issue occurred when SetWinEventHook is called in void InstallWinEventHook(object _), even with an empty handling function the lag appear. I don't know if there is a way around it. Best regards.

sylvainpiron avatar Nov 28 '22 14:11 sylvainpiron

Yes - I don't now whether the performance of this has changed. The better approach is to handle the WinEvents on a separate thread. The only trouble I see with that is getting the window class names, which was problematic when not called on the main thread. But I think we might keep a dictionary or something to deal with this.

govert avatar Nov 28 '22 14:11 govert

Would it be possible to not do any work until the window move/resize has completed, hiding any IntellisSense visuals at the start of the move/resize and making them visible again after?

markasam avatar Nov 28 '22 19:11 markasam

I don't think the problem is that we are doing too much work during the movements. The problem is that the mechanism (called WinEvents) we use to track all the various window changes, including the function list popping up, focus changes etc. is making the Excel window movement slow. With some work it will be possible to do this event tracking on a separate thread, which might not interfere with the movement. It was kind of like this initially, but it proved to be very hard to make things reliable. I'll try to have a look over the holidays.

govert avatar Nov 28 '22 20:11 govert

I too am seeing the issue when simply calling SetWinEventHook() in a native xll and doing nothing in the handler (I previously missed sylvainpiron's post). The minEvent and maxEvent arguments for SetWinEventHook() can be used, however, to avoid martialing unnecessary events. The issue goes away for me, e.g., if EVENT_OBJECT_LOCATIONCHANGE (which gets fired repeatedly as the window moves) is excluded from the range. IntelliSense unfortunately appears to use this event, but if EVENT_SYSTEM_MOVESIZESTART and EVENT_SYSTEM_MOVESIZEEND could be handled instead, that would be a solution.

When I set hooks for the following ranges (three calls to SetWinEventHook()), which includes all of the other events IntelliSense appears to rely on, the issue does not occur; the window moves as expected.

EVENT_SYSTEM_MOVESIZESTART 0x000A EVENT_SYSTEM_MOVESIZEEND 0x000B

EVENT_OBJECT_CREATE 0x8000 EVENT_OBJECT_DESTROY 0x8001 EVENT_OBJECT_SHOW 0x8002 EVENT_OBJECT_HIDE 0x8003 EVENT_OBJECT_FOCUS 0x8005 EVENT_OBJECT_SELECTION 0x8006

EVENT_OBJECT_TEXTSELECTIONCHANGED 0x8014

In any case, given the apparent expense of Windows martialing events in this way, it probably makes sense to use minEvent and maxEvent to restrict SetWinEventHook() even if LOCATIONCHANGE continues to be handled but on a separate thread.

markasam avatar Nov 29 '22 14:11 markasam

@markasam Thank you for checking this. It sounds promising and a much easier change than I had in mind, if we don't have to change to a separate thread. We just handle EVENT_SYSTEM_MOVESIZEEND as the trigger for the location update. Then the IntelliSense window won't move while the main Excel window moves, but I don't think that's too important.

govert avatar Nov 29 '22 16:11 govert

@govert, I have fixed this issue in a local branch. Also, I have fixed that the intellisense tooltip basically doesn't update to show the function arguments when I type in a formula (or move the text caret around) in the latest version of Excel. I suspect it's related to a recent Office/Windows update, such that Excel no longer sends the same Window events.

Can you give me permissions to push the branch, such that I can create a PR?

sbolofsson avatar Jan 17 '23 21:01 sbolofsson

@sbolofsson the github workflow is that you would fork the repo in your own name, then create a branch for your changes, push your changes to your personal fork, and then create a Pull Request back to @govert 's repository for him to review and merge as appropriate.

You would not need any permissions to @govert 's repository for this workflow.

As per: https://github.com/Excel-DNA/IntelliSense/pull/125

bevanweiss avatar Jan 17 '23 21:01 bevanweiss