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
670 stars 96 forks source link

Word Addin fails to load correctly (the Office.onReady isn't called) for some users, only started happening in last few weeks #1824

Open richie5um opened 3 years ago

richie5um commented 3 years ago

Expected Behavior

Addin loads successfully - the onReady is called into our webapp.

Current Behavior

Addin fails to fully load - seems as though the onReady isn't being called - although we've been unable to diagnose fully as we can't see the console on some installs of Word (right-click in sidebar, then 'inspect').

This issue seems to have started in the last few weeks. We had no problems in this area prior to that. It works on all customers machine successfully.

Steps to Reproduce, or Live Example

We are unable to repro. We've tried all combinations of Word, Edge/IE11, +/- WebView2

Context

We believe we’ve encountered two separate Microsoft Word issues over the past week, both of which result in our Addin not loading.

In the index.html for the addin we show a placeholder div, this then gets replaced by our app when the Office.onReady callback fires.

This is the main index.html that is loaded by Word (in the sidebar). The key work happens in the MS host file “office.js”, which initializes the all the needed bits and then calls our callback in ‘Office.onReady()’ – see the file below. image

When the onready fires, we remove the ‘loading, please wait…’ and replace with our App – see below. image The problem we’ve seen is that on some machines (and some that definitely used to work correctly) they don’t get passed the ‘Loading, please wait…’ stage. This happens before any angular code runs, so should always work fine.

In the cases we’ve been able to see the console (not all sidebar instances allow you to see the dev console) for those machines that don’t work, there is a message that ‘Warning: Office.js loaded outside of Office client’, and it doesn’t load. We can go to ‘https://office.myaddin.com’ directly in a browser (i.e. definitely not in a office client) and it will still load our app – as office.js seems happy to still call the onready callback.

This screenshot from a problematic machine has two things that may be relevant to this problem: image

The initial call into our sidebar is https://office.myaddin.com/?et=XXXX&_host_Info=Word$Win32$16.01$en-US$$0

This seems important as once the hostInfoValue is set in SessionStorage, this will prevent the onready callback from firing if it doesn’t match the actual client host. You can see this behaviour by going to this link in your browser:

You’ll notice that won’t load anymore, until you remove the ‘hostInfoValue’ from the browsers session storage

NOTE: From our investigations, the working instances of Word have a different initial URL that triggers for the sidebar, they are just https://office.myaddin.com (without the query params).

You can see there is a ‘tracking prevention blocked access to storage’. I believe this gets fired on a ‘read’ of the sessionstorage, which would, if it is being blocked, correlate with the hostInfoValue / ?et situation described above. I’m not aware of how we (or the user) can change the tracking prevention for browser instanced used within Word. I tried to change that in the locally installed version of Edge (to disable tracking prevention), but it didn’t help.

One some other machines, they also fail to load the sidebar (they demonstrate the same result ‘Loading, please wait…’, but we don’t know why they fail either). We’ve tried on our own VMS with different combinations of Windows, Word (2016 Standard, 2016 ProPlus, 2016 O365, 2019 O365). One customer was successfully using Word Standard 2016 with the addin until last week, and now it no-longer loads.

Please can you help us diagnose? Up until 1-2 weeks ago, we weren’t aware of any problems in this area. Has an update to Windows/Word/OfficeJs caused these issue?

Your Environment

jipinshi commented 3 years ago

@yihuax, can you take a look?

yihuax-zz commented 3 years ago

Sure.

From: jipinshi @.> Sent: Monday, April 26, 2021 6:11 PM To: OfficeDev/office-js @.> Cc: Yihua Xiong @.>; Mention @.> Subject: Re: [OfficeDev/office-js] Word Addin fails to load correctly (the Office.onReady isn't called) for some users, only started happening in last few weeks (#1824)

@yihuaxhttps://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fyihuax&data=04%7C01%7Cyihuax%40microsoft.com%7Cb7ec5fae048b4cdf933908d9091941c5%7C72f988bf86f141af91ab2d7cd011db47%7C0%7C0%7C637550826349695471%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=6T6S4veMMV6eP7x2tZv0uA5LJqckOQluAfAej6L1KPM%3D&reserved=0, can you take a look?

- You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FOfficeDev%2Foffice-js%2Fissues%2F1824%23issuecomment-827237682&data=04%7C01%7Cyihuax%40microsoft.com%7Cb7ec5fae048b4cdf933908d9091941c5%7C72f988bf86f141af91ab2d7cd011db47%7C0%7C0%7C637550826349695471%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=lYXjhcvOarbwwqYzylw2JbKd%2F27jP1VAED%2FwIiWm5JU%3D&reserved=0, or unsubscribehttps://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAEOBXFWPGWN76UM6LTV7ZMLTKYFIRANCNFSM43STS4QQ&data=04%7C01%7Cyihuax%40microsoft.com%7Cb7ec5fae048b4cdf933908d9091941c5%7C72f988bf86f141af91ab2d7cd011db47%7C0%7C0%7C637550826349705430%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=LU9jz2n%2FINptOF5MrAD6bPndpU3z%2BVS0lGvtqugw940%3D&reserved=0.

yihuax-zz commented 3 years ago

@Jiping @.***>, I used both a legacy taskpane add-in and a shared runtime add-in in Word win32, and both called onReady correctly.

Could be something wrong with the customer's javascript code, which looks quite complex?

Thanks! Yihua

richie5um commented 3 years ago

Hi @yihuax , our addin has been working correctly for many months. It only started to have this problem in the last few weeks - and we've not made any changes.

Do you know why sometimes the add-in opens with a URL like https://office.myaddin.com/?et=XXX&_host_info=XXX (replace 'XXX' with actual values), and sometimes it is just https://office.myaddin.com?

Have you seen the 'tracking prevention blocked access' warning that seems to cause problems for the office.js script reading the hostInfoValue from SessionStorage? When I looked at the minified office.js file, it appeared that if the value from hostInfoValue (SessionStorage) didn't match the value obtained from 'agaveHost.GetHostInfo()'. I may have misunderstood the minified code, but it seemed that if they didn't match, then the callbacks to call onReady didn't fire. And, if the tracking prevention blocked access was causing problems to read the value from SessionStorage, then those values wouldn't match.

yihuax-zz commented 3 years ago

Thank you Rich. Could you see whether you can narrow down the issue and then use Script Lab to repro it?

Thanks! Yihua

richie5um commented 3 years ago

Thanks. I’ll try to repro - and with script lab too.

Do you know the answers to the other questions in my previous comment? Thanks.

yihuax-zz commented 3 years ago

That is something I don't know. Sorry. Maybe you can start a new topic in github?

Thanks! Yihua

From: Rich Somerfield @.> Sent: Tuesday, April 27, 2021 2:44 PM To: OfficeDev/office-js @.> Cc: Yihua Xiong @.>; Mention @.> Subject: Re: [OfficeDev/office-js] Word Addin fails to load correctly (the Office.onReady isn't called) for some users, only started happening in last few weeks (#1824)

Thanks. I'll try to repro - and with script lab too.

Do you know the answers to the other questions in my previous comment? Thanks.

- You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FOfficeDev%2Foffice-js%2Fissues%2F1824%23issuecomment-827950625&data=04%7C01%7Cyihuax%40microsoft.com%7Cee7569d2aefb463f617d08d909c58164%7C72f988bf86f141af91ab2d7cd011db47%7C0%7C0%7C637551566148858681%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=katd1O41bUErzhR1TSbmDrEUCswscCl%2FObhiLXnpxD4%3D&reserved=0, or unsubscribehttps://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAEOBXFSA5LNGPFVM5VZC2NLTK4VYJANCNFSM43STS4QQ&data=04%7C01%7Cyihuax%40microsoft.com%7Cee7569d2aefb463f617d08d909c58164%7C72f988bf86f141af91ab2d7cd011db47%7C0%7C0%7C637551566148858681%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=OmuqVM%2Bkv8VwXmy0BhRIoEyjknDV7pNGyKe5urUtFtk%3D&reserved=0.

ndreisg commented 3 years ago

Got report from a customer with the same issue but in Excel. The issue appeared about a week ago. Before it was working as expected. We didn't change anything in our Add-In recently.

Same warning is displayed in the customers console: Warning: Office.js is loaded outside of Office client

The customer also reported that this only appears in one particular Excel Workbook. When he creates a new Workbook the Add-In is loading as expected.

Note: The warning about tracking prevention seems to be unrelated since I see this warning also when the Add-In is loading correctly.

yihuax-zz commented 3 years ago

Could you give us the add-in files and the application files so we can try reproducing the issue?

Thanks! Yihua

ghost commented 3 years ago

This issue has been automatically marked as stale because it is marked as needing author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment. Thank you for your interest in Office Add-ins!

richie5um commented 3 years ago

I'm not able to send you my addin files, and as I'm unable to reproduce locally, I wouldn't know if this was failing anyway.

Are you able to get someone to answer the two questions above please?

As far as I can tell, the ?et... and tracking prevention caused the issue. I've been unable to reproduce the ?et.... query params on my local machine / VMs.

yihuax-zz commented 3 years ago

I don't know the answers but someone gave me a short answer for the first question:

"?et is the EToken, and it'll be appended for OMEX/FPA/Side-loaded registry if we have a token."

So you don't need to care about it.

Thanks! Yihua

richie5um commented 3 years ago

Thanks. The presence of the ?et query param, seems to also have the _host_info query param too, and if that is present, and the tracking prevention causes hostInfoValue to be prevented from reading, then that seems to cause the addin to not load.

?!!?

swiftinitdotcom commented 2 years ago

I have exact same issue suddenly in excel addin. This was working few months back. dialogSSOv1.html:1

Tracking Prevention blocked access to storage for https://appsforoffice.microsoft.com/lib/1/hosted/office.js. OSF.DDA.Error code: 7000 message: "You don't have sufficient permissions for this action." name: "Permission Denied"

Arvini92 commented 2 years ago

Hi @yihuax , our addin has been working correctly for many months. It only started to have this problem in the last few weeks - and we've not made any changes.

Do you know why sometimes the add-in opens with a URL like https://office.myaddin.com/?et=XXX&_host_info=XXX (replace 'XXX' with actual values), and sometimes it is just https://office.myaddin.com?

Have you seen the 'tracking prevention blocked access' warning that seems to cause problems for the office.js script reading the hostInfoValue from SessionStorage? When I looked at the minified office.js file, it appeared that if the value from hostInfoValue (SessionStorage) didn't match the value obtained from 'agaveHost.GetHostInfo()'. I may have misunderstood the minified code, but it seemed that if they didn't match, then the callbacks to call onReady didn't fire. And, if the tracking prevention blocked access was causing problems to read the value from SessionStorage, then those values wouldn't match.

Yes, have the same issue. For me, it begins with new office UI update. For old version, it works fine. https://github.com/OfficeDev/office-js/issues/2280 https://stackoverflow.com/questions/70154239/word-addin-truncates-the-url-that-we-pass-to-sourcelocation

yihuax-msft commented 2 years ago

@AbidRahman-MSFT, Do you know who is familiar with the add-in loading issue?

AbidRahman-MSFT commented 2 years ago

@madhavagrawal17 may be able to help us with these issues.

longseespace commented 2 years ago

I'm having the same issues. Sometimes Office.onReady fulfills, but most of the time it doesn't. Very random.

I was working consistently a few weeks ago.

hbnrmx commented 2 years ago

Hi everyone, I encountered a similar issue in multiple office addins that tried to open a new tab for authentication purposes. During the process, it seems like an invalid hostInfoValue is written to sessionStorage so the new tab will crash before Office.onReady is invoked.

e.g. if the hostInfoValue was set in Word:

Uncaught Sys.ArgumentNullException: Sys.ArgumentNullException: Value cannot be null.
Parameter name: conversationId
    Microsoft_Office_Common_ClientEndPoint https://appsforoffice.microsoft.com/lib/1.1/hosted/word-web-16.00.debug.js:4762
    Microsoft_Office_Common_XdmCommunicationManager$connect https://appsforoffice.microsoft.com/lib/1.1/hosted/word-web-16.00.debug.js:5269
    OSF_InitializationHelper$setAgaveHostCommunication https://appsforoffice.microsoft.com/lib/1.1/hosted/word-web-16.00.debug.js:6045
    OSF__OfficeAppFactory_initialize$onAppCodeAndMSAjaxReady https://appsforoffice.microsoft.com/lib/1.1/hosted/office.debug.js:1825
    validateFunction https://appsforoffice.microsoft.com/lib/1.1/hosted/office.debug.js:350
    waitForFunction https://appsforoffice.microsoft.com/lib/1.1/hosted/office.debug.js:362
    OSF__OfficeAppFactory_initialize$onAppCodeReady https://appsforoffice.microsoft.com/lib/1.1/hosted/office.debug.js:1952
    OSF_OUtil_loadScript$onLoadCallback https://appsforoffice.microsoft.com/lib/1.1/hosted/office.debug.js:481
    loadScriptInternal https://appsforoffice.microsoft.com/lib/1.1/hosted/office.debug.js:516
    loadScript https://appsforoffice.microsoft.com/lib/1.1/hosted/office.debug.js:339
    OSF__OfficeAppFactory$initialize https://appsforoffice.microsoft.com/lib/1.1/hosted/office.debug.js:1970
    OSF__OfficeAppFactory https://appsforoffice.microsoft.com/lib/1.1/hosted/office.debug.js:1997
    <anonymous>

a minimal reproduction can be found here:

<!DOCTYPE html>
<html lang="en">
  <body>
    <script>
      /**
       * set to false to reproduce the issue.
       */
      const WORKING_EXAMPLE = true

      const OFFENDING_VALUE = "Word|Web|16.00|DE-DE|912def62-00dd-4146-abbb-bfd1f28a74f0|||0"

      WORKING_EXAMPLE
      ? sessionStorage.removeItem('hostInfoValue')
      : sessionStorage.setItem('hostInfoValue', OFFENDING_VALUE)
    </script>

    <script src="https://appsforoffice.microsoft.com/lib/1.1/hosted/office.debug.js"></script>

    <script>
      Office.onReady(() => console.log('Office.onReady fired correctly.'))
    </script>
  </body>
</html>

Firefox seems to interpret the string as a weirdly sliced array?

Screenshot 2022-04-21 at 2 18 27 PM

Any ideas?

justmars commented 1 year ago

Also getting the same error in the dialog non-iframe popup:

Uncaught Sys.ArgumentNullException: Sys.ArgumentNullException: Value cannot be null.
Parameter name: conversationId

Tried following the delete / change hostInfoValue in SessionStorage route suggested above which removes the Value cannot be null however prevents Office JS from initializing properly (see log Warning: Office.js is loaded outside of Office client) and thus:

Office.context.ui.messageParent(truthValue) 

... results in:

Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'messageParent')
    at (index):222:29

This problem only occurs in Office for Web but works fine in Office for Mac.