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
690 stars 95 forks source link

Problems when Add-in is executed in multiple Excel documents #3048

Open danielpdev opened 1 year ago

danielpdev commented 1 year ago

I have problems executing an office add-in in multiple Excel documents. One stops running when both are executed in the same time.

To reproduce:

Conclusion: Switching focus between documents will pause the execution of the functions on excel document that is not in focus and will result in some functions not even displaying the result and have unpredictable behaviour.

stackoverflow issue 2.7 years old https://stackoverflow.com/questions/61465017/office-js-problems-when-addin-is-executed-in-multiple-excel-instances

wh1t3cAt1k commented 1 year ago

@gmichaud I wonder if this is what you have been observing on Mac all this time when multiple documents were open.

gmichaud commented 1 year ago

@danielpdev on which platform are you observing this? I'm on Excel for Mac, and if I switch to a different window the calculation stops. Excel for Windows doesn't seem impacted by this issue. It's very annoying, especially when you know the refresh will take 1 minute and you have to sit there and wait...

ruijiaMS commented 1 year ago

Hi @danielpdev, I searched our bug list and did find that there is a history about it, and it had been closed 2 years ago. I try to investigate the performance for win32 and excel online. Both are works well. However, when I change the browser core from webview2 to webview, the scripts run very slow if it is not in the foreground. So, basically, I guess there are something are updated from webview to webview2. or maybe the same issue to Mac browser core as well. We strongly suggest that you can use webview2 to ensure it works well. Another suggestion is that excel online could be also a good option for you if it can meet your requirement.

gmichaud commented 1 year ago

@ruijiaMS some spreadsheets used by our customers take a few minutes to recalculate, it’s rather annoying to have to sit there with Excel in the foreground or have to switch to Excel Online if you want to avoid this issue. This is one more reason to bring WebView2 to Mac - we have other memory/performance related issues with Safari that would be resolved if Excel for Mac used the same engine as Excel for Windows.

ruijiaMS commented 1 year ago

@gmichaud thanks for your explanation, I have delivered this issue to Mac team and they will take a look. Any update will post here~

ruijiaMS commented 1 year ago

@danielpdev we can hardly repro this issue on Mac. Could you please provide a screen record video to help me understand how this issue works. Thanks!

gmichaud commented 1 year ago

@ruijiaMS I just recorded a video that demonstrates the problem I mentioned above. In my case, I'm switching to a different application, but I suspect the underlying issue is the same.

Link: https://www.loom.com/share/402f285c8d31439db786b8a8925ba570

In the video, I replicate the issue with our add-in (Velixo), as well as another add-in that I found in the store. I've attached the file I used for your convenience below.

Recalc when out of focus with Safari.xlsx

gmichaud commented 1 year ago

@ruijiaMS I would like to mention that the issue described above only happens with Excel for Mac -- it doesn't happen with Excel Online under Safari. I initially thought it was some sort of performance optimization in Safari, but interestingly it's something else...

gmichaud commented 1 year ago

@ruijiaMS did you get a chance to review this?

ruijiaMS commented 1 year ago

I delivery this issue to the Mac team and they are looking into it now. Any update will post here.

gmichaud commented 1 year ago

@ruijiaMS is there any update on this issue? It is effectively preventing Mac users from doing anything during recalculation of a workbook, which may take up to a few minutes.

ruijiaMS commented 1 year ago

We will keep monitoring on this issue, any update will let you know timely. Thanks!

gmichaud commented 1 year ago

@ruijiaMS it's been more than 10 months since this was filed; has this been reviewed by the Mac team? Thanks!

SiruiSun-MSFT commented 7 months ago

Hi @gmichaud, Thanks for waiting! We are still active working on this issue. And we can indeed repro the issue you mentioned above through the FastTrack Add-in you recommended. However, during our investigation, we have tried using UDF in VBA and two CustomFunctions using SharedRuntime or JSRuntime, but all of the three cases don't repro this problem, which block our progress. Therefore, we would like to know from you, do you have any other settings for your Custom Function?

gmichaud commented 7 months ago

@SiruiSun-MSFT thanks for your response. Are you working with @trigurl or reviewing this in context with issue #4004 I referenced above? My hunch is that Safari is aggressively throttling background activity which could cause explain both this issue and #4004. @trigurl confirmed that she replicated the issue and to have at least an idea how to fix it.

Might be relevant, but our addin uses shared workers and does HTTP calls to request data. @wh1t3cAt1k anything you’d like to add? We can set you up with a license and instructions to use our own plugin if that can help replicate the issue

wh1t3cAt1k commented 7 months ago

Correct @gmichaud a lot of the activity in our add-in happens outside of the main context, either in dedicated web workers and/or in the shared worker. I don't think I have anything else to add, however, I suspect it is highly likely that the root cause and solution of both this issue and #4004 are at least linked, if not the same.

wh1t3cAt1k commented 7 months ago

@gmichaud @SiruiSun-MSFT If that helps replication we can privately share:

SiruiSun-MSFT commented 7 months ago

Hi @gmichaud and @wh1t3cAt1k, thanks for your patience! We are now under communication with @trigurl to check whether these two cases share the same root cause, but no conclusion yet. Will keep you up to date with the progress. And to help us to speed up the investigation, we would like to invite you guys provide the resources you mentioned above, such as manifest, test account, repro file with CF filled in, and so on. Thanks in advance!

wh1t3cAt1k commented 7 months ago

Would you be able to provide a non-public channel for us to share?

SiruiSun-MSFT commented 7 months ago

Thanks for waiting here. We have created a forms survey to collect more information to debug/repro this issue. You can put anything you want to share with us here: https://forms.office.com/r/g27dkmH3hW. In addition, in order to share information such as files, you can provide your contact information to us through forms, and we will contact you directly. PS: Your participation in this survey is voluntary and confidential. The collected data will be used for issues investigation purposes only and will not be shared with any third parties. There is no guarantee of product changes based on feedback provided. Thanks!

wh1t3cAt1k commented 7 months ago

Velixo internal tracking item

wh1t3cAt1k commented 7 months ago

Dear @SiruiSun-MSFT I have responded to the email where you and Adrian Wu were in the copy, providing one more time the replication scenario and the necessary credentials. Thank you!

SiruiSun-MSFT commented 7 months ago

Got it. Thanks for your providing, and we are now under the active investigation. Will update here when we get some insights!

trigurl commented 6 months ago

Hi @gmichaud and @wh1t3cAt1k, what do we need to repro this with your Velixo add-in? In the video I see a login, can you create me a test account? I see that you've attached a spreadsheet.

Step by Step Repro:

1) Install Velixo then open the taskpane and login 2) Open the spreadsheet (should I use the one above?) 3) Click Refresh on the taskpane 4) Switch focus to another app while Refresh is calculating....

wh1t3cAt1k commented 6 months ago

@trigurl as mentioned above, I have provided the credentials to @SiruiSun-MSFT and Adrian Wu previously, did they pass it to you? If not, how can I share directly with you to unblock?

wh1t3cAt1k commented 1 month ago

Based on our recent chat with @AdrianWu, this has been confirmed by MSFT internally to be a limitation of both the Web Workers and Shared Workers on Apple's WKWebView which is used by Excel. The background thread computation appears paused as soon as the focus switches to another application.

This has already been reported by MSFT to Apple, but the ticket has not yet been acknowledged. We agreed that the Office.js team will follow up and provide an update when possible.

cc @SiruiSun-MSFT @trigurl