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
667 stars 94 forks source link

Spam addins not working for Monthly Enterprise Channels. #4676

Closed glr0221 closed 4 weeks ago

glr0221 commented 1 month ago

Provide required information needed to triage your issue

Spam addins are successfully installed but get stuck/hangs when ran/opened in an Outlook instance when using monthly enterprise channel.

Your Environment

Expected behavior

When clicking the spam addin button, a popup will be launched and the code of the spam addin will be executed.

Current behavior

  1. The spam addin button shows.
  2. Clicking the spam addin button shows the dialog.
  3. Clicking report button on the dialog results to a hanging/stuck addin.

Steps to reproduce

  1. Create a very simple spam addin that runs on Classic Outlook. Or you can use (https://github.com/OfficeDev/Office-Add-in-samples/tree/main/Samples/outlook-spam-reporting)
  2. Ensure that your outlook instance is in monthly enterprise channel.
  3. Sideload the manifest of your addin on the outlook instance.
  4. Click on the spam addin button.
  5. Click on report.
  6. Addin gets stuck/hangs.

Link to live example(s)

NA

Provide additional details

  1. If we use new look outlook the spam addin works correctly.
  2. If we enable the debug registry for the addin (https://learn.microsoft.com/en-us/office/dev/add-ins/outlook/debug-autolaunch?tabs=windows#mark-your-add-in-for-debugging-and-set-the-debugger-port) then the addin works.
  3. I did some network capture and found out clicking the report button does not download the necessary javascript files and resources.

Context

Useful logs

Thank you for taking the time to report an issue. Our triage team will respond to you in less than 72 hours. Normally, response time is <10 hours Monday through Friday. We do not triage on weekends.

glr0221 commented 1 month ago

any feedback on this @exextoc? Thank you.

exextoc commented 1 month ago

We tried reproing this on our builds, and it should work correctly. (we tried both our internal add-in and the manifest that you provided).

I did some network capture and found out clicking the report button does not download the necessary javascript files and resources.

This is suspicious. This will certainly cause an error if the bundle.js file is not downloaded. Can you check if the bundle is there?

C:\Users\[username]\AppData\Local\Microsoft\Office\16.0\Wef\[GUID]\[Encoding]\Javascript\[Add-in ID]\bundle.js

We simulated the bundle not downloading, and got the same results as you.

If we enable the debug registry for the addin (https://learn.microsoft.com/en-us/office/dev/add-ins/outlook/debug-autolaunch?tabs=windows#mark-your-add-in-for-debugging-and-set-the-debugger-port) then the addin works.

This is also interesting. In that setting the debug setting will change the JS engine to V8 instead of Chakra. (note that MEC builds are still running Chakra, but the Monthly CC builds have moved to V8). So if your JS bundle contains some things that are not compatible with Chakra this could be the cause.

However, we did test your sample manifest with Chakra and it seemed to work, so I think likely this may be a bundle.js download issue instead.

glr0221 commented 1 month ago

Hello @exextoc,

I have tested again with the monthly enterprise channel and found that all the Javascript files are downloaded during the loading of outlook. So in effect all bundle.js files are present.

The part that is interesting though is that in the current/beta channels, when the report button is clicked, it tries to get a copy of the JS file and allowed.json file. In the failing version both files are not downloaded. Here is what I did :

  1. Opened Outlook with 2 instances (different AppIDs) of the same spam button. (Opening outlook downloads all the JS files for addins.)
  2. Enabled debugging for 1 of the AppIds.
  3. Deleted the bundle.js for both instances.
  4. Clicked on debuggable instance and found that it created a bundle.js file and a map file in the WEF folder.
  5. Clicked on non-debuggable instance and found that it did not create the bundle.js file.

I don't know about chakra, but if our code works in your tests, then it should work with the MEC-Chakra version right? How do we know if the Outlook client is chakra or V8 powered? Is there a test we can ask our customers to run to determine the JS engine? Are other channels (Current, semi-annual, etc...) powered by chakra as well?

Any advice on how to proceed? Or is there a plan to migrate everything to V8 any time soon?

Thank you very much.

Adrian-MSFT commented 1 month ago

I have tested again with the monthly enterprise channel and found that all the Javascript files are downloaded during the loading of outlook. So in effect all bundle.js files are present.

This seems to indicate that the bundle download is working as intended - the bundle files should be downloaded when Outlook boots

However, we're a bit confused by the next part:

The part that is interesting though is that in the current/beta channels, when the report button is clicked, it tries to get a copy of the JS file and allowed.json file. In the failing version both files are not downloaded. Here is what I did :

By "failing version", do you mean MEC? Or by "failing version", do you mean the add-in that is not marked for debugging from your steps below?

  1. Opened Outlook with 2 instances (different AppIDs) of the same spam button. (Opening outlook downloads all the JS files for addins.)
  2. Enabled debugging for 1 of the AppIds.
  3. Deleted the bundle.js for both instances.
  4. Clicked on debuggable instance and found that it created a bundle.js file and a map file in the WEF folder.
  5. Clicked on non-debuggable instance and found that it did not create the bundle.js file.

These steps are executed in MEC, correct? Not current/beta channels? When you set the debug registry key for an add-in, Outlook will be more aggressive in downloading the bundle in order to help developers with debugging, which is why you are seeing this happening in the add-in marked for debugging.

I don't know about chakra, but if our code works in your tests, then it should work with the MEC-Chakra version right? How do we know if the Outlook client is chakra or V8 powered? Is there a test we can ask our customers to run to determine the JS engine? Are other channels (Current, semi-annual, etc...) powered by chakra as well?

Any advice on how to proceed? Or is there a plan to migrate everything to V8 any time soon?

Based on our testing, yes, the code works in MEC-Chakra version. Unfortunately, there is no easy way to check what version of the engine is running, but V8 should be enabled now for all channels except MEC and semi-annual, as of now. MEC V8 enablement should come soon in the near future.

glr0221 commented 1 month ago

Thank you for all the answers @Adrian-MSFT .

You are right, all these tests were done in the MEC version. And that when I was saying 'failing version', I meant the addin without the debug-registry enabled. This sentence explains what I was seeing :

When you set the debug registry key for an add-in, Outlook will be more aggressive in downloading the bundle in order to help developers with debugging, which is why you are seeing this happening in the add-in marked for debugging.

May I know how I can test the code in MEC-Chakra version like what you did? I intend to test our releases against it. As for V8 enablement, do you have any timelines that you can share? Will V8 be enabled for semi-annual as well? Thank you very very much.

Adrian-MSFT commented 1 month ago

@glr0221 Since MEC is not on V8 yet, running any spam add-in in MEC (without the debug registry key set) should be testing the code against the MEC-Chakra version.

I reached out to the team that owns our JS engines. Unfortunately, they do not have any concrete timelines to share for the V8 enablement in these channels.

glr0221 commented 1 month ago

Thank you for all your answers @Adrian-MSFT . Thank you also for reaching out to your internal teams in hope of getting an update on the V8 roll out.

I will check and see if I can figure this one out. I will have to do trial and error to find the offending code. Thanks again.

glr0221 commented 4 weeks ago

@Adrian-MSFT @exextoc

After a lot of trial and error, and line by line process of elimination, I found the piece of code causing a crash in chakra JS engines. It was a line trying to add/concatenate two structures.

I wish to thank you all greatly for your support and all your responses. Without your guidance and help, I would have never found the offending code. I would have proceeded blindly with the debug registries enabled.

Thank you all so much and closing this ticket.