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

🔥🐛 Shared runtime gets destroyed (?) on Mac when taskpane is closed and workbook is out of focus #4004

Closed wh1t3cAt1k closed 4 months ago

wh1t3cAt1k commented 10 months ago

Your Environment

Expected behavior

Excel keeps the shared runtime alive even if the focus goes away from the application.

Current behavior

We are observing that when

  1. Task pane is closed, and
  2. The workbook is out of focus for some time,

either Excel or Mac OS X "kills" the shared runtime of the add-in. So, when you return back to the source workbook, neither of the toolbar buttons are working anymore and functions are not calculating

https://www.loom.com/share/9ef6530e30bd43a386b181fe4f4c8492

As a result of this, the ribbon button handlers stop reacting, I believe @gmichaud also observed that all custom functions in the file get stuck in #BUSY? if you attempt to calculate.

Steps to reproduce

  1. Launch Excel
  2. Install Velixo add-in
  3. Open Vx button from the home tab, verify that Velixo NX ribbon has appeared and e.g. the "Status" button works.
  4. Close the task pane - very important step.
  5. Move focus to another window
  6. Use Mac as usual and wait for 20-25 minutes (do not bring the focus back to the Excel window)
  7. After 20-25 minutes, go to the Velixo NX ribbon and try click Connection Manager or Status view

Actual result: no reaction to the buttons.

Context

This issue has ruined a few sales demos for us because we could not understand why the add-in became unresponsive.

This is only replicable on Mac, not on Windows or Excel Online, we checked. However, our CEO uses a Mac and quite a few of our customers are Mac-only.

Velixo internal tracking item

gmichaud commented 10 months ago

I can confirm when this happens that all custom functions get stuck in #BUSY! as well until we re-open the add-in side panel. The issue is easy to replicate and is Mac only.

gmichaud commented 10 months ago

Here's a recording demonstrating the issue on Mac: https://www.loom.com/share/0fd0b22b33b843d983f6f70a4f399ab5

Fast forward to 20:00 in the video if you want to see what happens after the add-in "dies" from inactivity.

As mentioned above, this only happens on Excel for Mac, and does not happen if you keep side-panel open.

wh1t3cAt1k commented 9 months ago

@zhenhuangMSFT just following up as this is still happening and is a high-severity issue for us. We would appreciate if this could be investigated on your end 🙏

zhenhuangMSFT commented 9 months ago

Hi @m-hellesen, could you please share the investigation results here?

wh1t3cAt1k commented 9 months ago

@zhenhuangMSFT @m-hellesen still hoping for an update from you...

mhelles commented 9 months ago

We are continuing to dig into this and appreciate your patience.

trigurl commented 8 months ago

Hi I'm helping looking into this.

trigurl commented 8 months ago

@wh1t3cAt1k do I need an account to use this addin? I don't see a Status button. All I see is "Connection Manager" and it's blank with a blue "Add" button.

gmichaud commented 8 months ago

@trigurl you don't need to add a connection to replicate the issue.

Replication steps:

We think that the webview/JavaScript runtime simply gets killed due to inactivity when you close the task pane. Issue doesn't open if you keep task pane open, and issue does not happen on Windows.

trigurl commented 8 months ago

OK after 25 minutes, I clicked on Status and get "Velixo NX is working on your Status" in the status bar. Seems to be there for a few minutes, I then just go to Home and click on the button to bring the taskpane up. The status bar message goes away, and I get the taskpane with the Get started page. When I click Connection Manager, something flashes across the status bar quickly and I can't read it, while the taskpane stays on the Get Started page. When I click on Status, same thing, some text quickly flashes in the status bar but the initial taskpane from Home still has Get Started.

gmichaud commented 8 months ago

I clicked on Status and get "Velixo NX is working on your Status" in the status bar.

This always happen when you click a button in the ribbon, and it gets stuck forever. That is a separate issue we filed a long time ago that still hasn't been fixed. Reference: #2877

Seems to be there for a few minutes, I then just go to Home and click on the button to bring the taskpane up.

You have hit the bug already. The task pane always shows up when you click Status or Connection manager. However, after +/- 20 minutes of inactivity with the task pane closed, the add-in completely dies, and none of the buttons in the ribbon are responsive. The only way to "revive" the add-in is to go to the Home tab and click "Velixo". Here's the normal behaviour of these buttons: https://www.loom.com/share/e59200273746485b8369b126ffb69426

Important this issue not only impacts the ribbon -- all the custom functions get stuck in #BUSY! status.

It is as if the entire add-in runtime gets shut down. I believe you need to determine what shuts it down and find a way to prevent this from happening after 20-25 minutes.

This problem is Mac-specific, and does not happen on Excel for Windows.

trigurl commented 8 months ago

OK do you recall when this was working? It might help to narrow down what change might have caused a regression. There's not timeout for shared runtime when I searched. And I set a breakpoint in the code that shuts down the runtime and it was never hit even though I hit the bug. I will need to consult my colleague, the area expert.

I tried the steps to get the Connection Manager webpage to appear, it seems that I need to click the Get Started button otherwise I can never get that page to appear. So here are my steps:

1) Install Velixo add-in in Excel 2) Click on the Vx button in the Home tab, this brings up a taskpane then click on Get Started button. A dialog comes up but I don't sign in, just dismiss it. The taskpane then displays a "Loading" page which takes a bit of time but less than a minute before showing Connection Manager. Go to the Velixo custom tab in the Ribbon and click on Status button, make sure Status page comes up in the taskpane. 3) Close the Velixo taskpane (very important) and set focus on some other window. I have a breakpoint on AgaveViewController::shutdown, AgaveViewController::webViewDidCloser, CSandboxManager::CreateSandbox on my side. 4) Back after 25 minutes, go to the Velixo customer tab, click on Status button.

Results

task pane never comes up and Status bar says "Velixo NX is working on your Status" If you click on Connection Manager button in the Velixo tab the status bar changes to "Velixo NX is working on your Connection Manager." I don't hit my breakpoint at all.

Expected

task pane should appear and it should land on the Status or Connection Manager page depending on the button you clicked. If you go to the Home tab and click on the Velixo button, it will launch the taskpane. Then click on the buttons in the custom tab will correctly bring up the page.

gmichaud commented 8 months ago

@trigurl we don't recall if this ever worked correctly, it took us a while to figure out that this issue was being caused by what appears to be a timeout. We just assumed something was wrong and relaunched Excel, until we discovered we could "revive" it by going to the home tab, which led us to do additional troubleshooting.

IMPORTANT this not only affects responsiveness of ribbon buttons, but more importantly custom functions also stop working. In my video above, I used the =VELIXOVERSION(), a simple custom function that returns our internal build number. It also gets stuck at #BUSY! in these cases.

Thanks a lot for all your help!

wh1t3cAt1k commented 8 months ago

As an additional testing hypothesis, I wonder if it could be the Safari WebKit webview playing tricks to conserve energy from a "page" that is not visible — judging by the fact that it's Mac-specific.

If so, perhaps there could be some strategy by Office.js to keep it alive.

gmichaud commented 8 months ago

@wh1t3cAt1k could be right -- another difference we see on Excel for Mac vs Windows is that custom functions stop calculating if we move focus away from Excel.

trigurl commented 8 months ago

@wh1t3cAt1k after debugging with a colleague we are going to see if it might be a Webkit issue. Will update when we have more info.

wh1t3cAt1k commented 8 months ago

@trigurl thank you! Hoping to hear there could be some dummy rendering or CPU spinning tactics to prevent WebKit from dying if it is indeed an engine issue.

trigurl commented 8 months ago

Hi, I need to seek advice from our Mac expert here. Will let you know if we have more info.

wh1t3cAt1k commented 7 months ago

@trigurl still waiting to hear back from you on this issue... Thank you 🙏

trigurl commented 7 months ago

Hi, I do have this issue logged on my plate so I haven't forgotten you. I'm trying to balance each request. I'm going to give something a try today and may have more questions for you.

wh1t3cAt1k commented 7 months ago

@trigurl thank you Angela, hoping to hear back from you.

trigurl commented 7 months ago

Hi, I did spend some time debugging it as far as when try to invoke the action and I'm seeing the callback fail. So I am needing to pull in a colleague that knows more about the webkit. He did mention that there are some known throttling issues when inactive.

gmichaud commented 7 months ago

@trigurl thanks for the update.

Since you mentioned inactivity, there's another Mac-specific issue that I would like to mention and that we have mentioned before in this comment: https://github.com/OfficeDev/office-js/issues/3048#issuecomment-1367444470 -- I have a recording of the issue here: https://www.loom.com/share/402f285c8d31439db786b8a8925ba570

Is this related to hidden page timer throttling in Safari? I never tried to look at these flags but I'm curious to see if disabling these optimizations in Safari could have any impact on Excel - https://apple.stackexchange.com/a/281356/152143

trigurl commented 7 months ago

OK I can confirm that we are getting throttled when inactive. It's not related to the hidden page timer throttling. We were able to test a hacky fix and it seems to work. The proper fix will need more time. Let me get back to you after we figure out when we can ship a fix.

wh1t3cAt1k commented 7 months ago

@trigurl just curious, who throttles us? Is it the WebKit engine?

wh1t3cAt1k commented 6 months ago

As discussed @SiruiSun-MSFT, please verify if @trigurl's "hacky fix" also gets rid of #3048...

trigurl commented 6 months ago

Issue https://github.com/OfficeDev/office-js/issues/3048 is a host specific issue. Excel is going to sleep. Xuan is looking into this. I'm going to close this one as I will be submitting a fix for the webview throttling.

gmichaud commented 4 months ago

This is now fixed and can be closed! @wh1t3cAt1k

wh1t3cAt1k commented 4 months ago

We confirm the fix in Excel for Mac 16.86! Thank you so much @trigurl !