OfficeDev / microsoft-teams-library-js

JavaScript library for use by Microsoft Teams apps
https://docs.microsoft.com/microsoftteams/platform/
Other
426 stars 194 forks source link

SDK initialization failed, "No Parent window found" error #2347

Open MajaEffenberg opened 3 months ago

MajaEffenberg commented 3 months ago

We are using version 2.20.0 of the teams-js libraryin our Angular application, which is displayed in Microsoft Teams Tabs.

During the initialization of SDK we start to see the following error reported in our app: Initialization Failed. No Parent window found.

Our implementation of initialization:

import {app} from '@microsoft/teams-js';

await app.initialize();

Error appears for TeamsMobile-iOS on iPhones with different OS (16_6_1, 17_4_1, 17_5_1). What can we do to avoid these errors as they appear randomly to different users? And why does this error appear at all?

Please let me know if you need any additional information.

AE-MS commented 3 months ago

Hi @MajaEffenberg. @KangxuanYe has been investigating reports like this and will reach out shortly to get more details.

KangxuanYe commented 3 months ago

Hi @MajaEffenberg, we are working with this and still trying to find a way to debug in our testing environment with a demo app. So far we don't request any information from your side but that will be a potential step in the future for investigation.

We appreciate your patience and will keep working on this. Hopefully we could reach back to you within this week and if you didn't hear me back, please feel free to tag me for asking progress. Thank you.

KangxuanYe commented 3 months ago

Hi @MajaEffenberg, could you please say more about this issue for us to investigate? Is this timeout happen when app is first loaded or it happens during authentication progress? Also, can this timeout issue be reproduced in your side? Thank you.

MajaEffenberg commented 3 months ago

Hi @KangxuanYe This error happens when the app is first loaded during initialization, not during authentication. We were not able to reproduce this error on our side. We tested Microsoft Teams App (version 6.4.0) on iPhone with iOS 17.3.1 and all works well and no error appear. But in last week we received more of these errors, reported for different users.

KangxuanYe commented 3 months ago

Hello @MajaEffenberg, if you cannot reproduce it, do you recall any steps you take for triggering the timeout issue? We will keep an eye on this issue and if next time you encounter this issue again, please come here and provide us steps and we can try to reproduce and investigate then.

Thanks for your report.

sschoeb commented 3 months ago

@KangxuanYe I'm a coworker of @MajaEffenberg.

This is very hard to reproduce (we did not manage it yet :/). But we get reports from our monitoring that our users hit this bug. More or less every day someone seems to be struggling with it.

Here some additional info we logged when the error happened. The value of it after the //

window.parent === window // true
window.parent === self // true
window.parent === top // true
window.self === window.top // true
window.parent == undefined // false
navigator.language "de-DE"
window.origin  // https://profile.micromate.ai
window.webkit == undefined // true
window.messageHandlers == undefined // true
window.nativeInterface == undefined // true
window.name // ''

Could there be any other value that would be interesting for you?

We do not have direct access to the users (as these are users of our customers). But based on the URL it seems that the user has opened a tab within Teams.

What we know: If you open the tab directly within a browser, you will hit this error. So opening an app that initializes the teams-js library in a tab outside teams fails. Which is intended behaviour and makes sense. And as the agent ist "Netscape 5.0 (iPhone; CPU iPhone OS 17_4_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 TeamsMobile-iOS -?" This is not the case here.

KangxuanYe commented 2 months ago

Hi @sschoeb, just to give you an update here that we are investigating this with logs you provided and we might need to reach another team for this issue since you are using Teams iOS. Thanks for your patience and we will share update here again once we find something or need something else from your side.

sschoeb commented 2 months ago

@KangxuanYe thanks for your update. I'm happy to provide you with all the needed info, just let me know.

KangxuanYe commented 2 months ago

Hi @sschoeb and @MajaEffenberg, sorry for waiting such a long time. We reached other teams and have discussions with them. They said that they acknowledged some similar issues that in old Teams iOS, there was an issue where nativeInterface object can get removed due to some cleanup bug. Thus, could you please specify what version of Teams iOS you are using? Thank you so much.

MajaEffenberg commented 2 months ago

@KangxuanYe Currently, we only know that error appears on iPhones with different OS (16_6_1, 17_4_1, 17_5_1), but we do not have information about the client's Teams iOS versions. How can we get this information directly in our application to log it along with the error? Is it possible to get that info from SDK?

KangxuanYe commented 2 months ago

Hi @MajaEffenberg, thanks for letting us know. I don't think we have a solution to know iOS Teams version directly for now but we are thinking of something to be built so that we could know that in the future. Ideally we would like to know everything after client logging is enabled, but as you could try, you will not know iOS Teams version from our current logging. We have brought this topic to iOS Teams team and we are still figuring it out. Hopefully we could have some updates soon. We really appreciate you keep working with us. Thanks.

sschoeb commented 2 months ago

@KangxuanYe thank you very much for your reply. As a side note, being able to ask teams-js about all the version details would be super helpful.

This as we face a lot(!) of bugs within teams and it would be much easier to have the understanding on which version the user is on.

So something like this would be great:

const version = app.host.versionInfo;

which then ends up in something like this:

{
    teamsAppVersion: 24165.1408.2960.3667
    clientVersion: 49/24053101421
}
sschoeb commented 2 weeks ago

@KangxuanYe Is there any update on this? I read in another thread that you have identified some issues (https://github.com/OfficeDev/microsoft-teams-library-js/issues/1181#issuecomment-2285088827). Does the mentioned logging system also include these version infos? Would be great.

KangxuanYe commented 1 week ago

Hi @sschoeb, sorry for late reply due to vacation.

Yes, those versions will be included in logging system. However, it is a little bit tricky for me to answer this question in mobile sides. Developers will take advantages if hosts in mobile platform use mobile host sdk. For your case, I am sorry to say that I don't think Teams iOS is integrating with iOS host SDK as far as I know, but we have started the conversation with Teams iOS team to see how to improve logging or with other approaches. The task is on our list and we would update here once we have some plans. For now, we are mostly focusing on web and desktop platform.

Thanks for your understand and patience.