Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SPFx in Teams Mobile no longer loads #9919

Open
2 of 9 tasks
thechriskent opened this issue Sep 15, 2024 · 4 comments
Open
2 of 9 tasks

SPFx in Teams Mobile no longer loads #9919

thechriskent opened this issue Sep 15, 2024 · 4 comments
Labels
area:spfx Category: SharePoint Framework (not extensions related) area:spfx-msteams Category: SharePoint Framework & Microsoft Teams support Needs: Author Feedback Awaiting response from the original poster of the issue. Marked as stale if no activity for 7 days. type:bug-suspected Suspected bug (not working as designed/expected). See “type:bug-confirmed” for confirmed bugs.

Comments

@thechriskent
Copy link
Collaborator

Target SharePoint environment

SharePoint Online

What SharePoint development model, framework, SDK or API is this about?

💥 SharePoint Framework

Developer environment

macOS

What browser(s) / client(s) have you tested

  • 💥 Internet Explorer
  • 💥 Microsoft Edge
  • 💥 Google Chrome
  • 💥 FireFox
  • 💥 Safari
  • mobile (iOS/iPadOS)
  • mobile (Android)
  • not applicable
  • other (enter in the "Additional environment details" area below)

Additional environment details

  • New Teams on iOS (reports of same issue happening in Android)
  • SPFx 1.19.0

Describe the bug / error

SPFx webparts hosted in teams no longer load in the mobile apps. The issue appears to be the call the teamsJs app context. In the vanilla webpart, this section of code causes the problem:

  private _getEnvironmentMessage(): Promise<string> {
    if (!!this.context.sdks.microsoftTeams) { // running in Teams, office.com or Outlook
      return this.context.sdks.microsoftTeams.teamsJs.app.getContext()
        .then(context => {
          let environmentMessage: string = '';
          switch (context.app.host.name) {
            case 'Office': // running in Office
              environmentMessage = this.context.isServedFromLocalhost ? strings.AppLocalEnvironmentOffice : strings.AppOfficeEnvironment;
              break;
            case 'Outlook': // running in Outlook
              environmentMessage = this.context.isServedFromLocalhost ? strings.AppLocalEnvironmentOutlook : strings.AppOutlookEnvironment;
              break;
            case 'Teams': // running in Teams
            case 'TeamsModern':
              environmentMessage = this.context.isServedFromLocalhost ? strings.AppLocalEnvironmentTeams : strings.AppTeamsTabEnvironment;
              break;
            default:
              environmentMessage = strings.UnknownEnvironment;
          }

          return environmentMessage;
        });
    }

    return Promise.resolve(this.context.isServedFromLocalhost ? strings.AppLocalEnvironmentSharePoint : strings.AppSharePointEnvironment);
  }

Steps to reproduce

  1. Generate a standard web part using 1.19.0
  2. Deploy to teams (I used a custom manifest)
  3. Try to load it on Teams Mobile
  4. Witness the never ending loading

Expected behavior

I expected the out of the box webpart to work as it did previously. It still works on desktop without issue, it's specifically within the Teams mobile client that the issue is seen.

The version of TeamsJS is controlled by SharePoint. The SPFx app shows it's using TeamsJS 2.12.0 but this isn't the actual version loaded on the page. This was working with TeamsJS 2.22.0 (last time I checked the version) but it appears the version was just updated to 2.24.0 in the past couple of days. This change is breaking all our stuff.

I have recreated the issue without changing a line of code in the default scaffolded web part which is why I believe the server side change to TeamsJS has caused this issue.

@thechriskent thechriskent added the type:bug-suspected Suspected bug (not working as designed/expected). See “type:bug-confirmed” for confirmed bugs. label Sep 15, 2024
@VesaJuvonen VesaJuvonen added Needs: Triage 🔍 Awaiting categorization and initial review. area:spfx Category: SharePoint Framework (not extensions related) area:spfx-msteams Category: SharePoint Framework & Microsoft Teams support and removed Needs: Triage 🔍 Awaiting categorization and initial review. labels Sep 16, 2024
@AJIXuMuK
Copy link
Collaborator

@thechriskent - thanks Chris for reporting the issue.
Could you please specify what mobile device you are using (Android/iOS and device)

I can't reproduce the issue on my side
image

@AJIXuMuK AJIXuMuK added the Needs: Author Feedback Awaiting response from the original poster of the issue. Marked as stale if no activity for 7 days. label Sep 16, 2024
@thechriskent
Copy link
Collaborator Author

Hi, Alex! Thanks for looking into this.

I am testing with iOS but we have reports of the same issue happening on Android as well. I generated a web part using 1.19.0 and selected React for the framework. The only line of code I have changed is line 28 where I'm passing the teamsJs.version for the description:

  public render(): void {
    const element: React.ReactElement<IHelloWorldProps> = React.createElement(
      HelloWorld,
      {
        description: this.context.sdks.microsoftTeams?.teamsJs.version || 'Not Teams',
        isDarkTheme: this._isDarkTheme,
        environmentMessage: this._environmentMessage,
        hasTeamsContext: !!this.context.sdks.microsoftTeams,
        userDisplayName: this.context.pageContext.user.displayName
      }
    );

Here it is working as expected within New Teams on the Mac:
image

Here it is in the neverending placeholder display in the iOS Teams app:
IMG_7313


Now, if I adjust the _getEnvironmentMessage() method like this:

private _getEnvironmentMessage(): Promise<string> {
    // if (!!this.context.sdks.microsoftTeams) { // running in Teams, office.com or Outlook
    //   console.log('teams version', this.context.sdks.microsoftTeams.teamsJs.version);
    //   return this.context.sdks.microsoftTeams.teamsJs.app.getContext()
    //     .then(context => {
    //       let environmentMessage: string = '';
    //       switch (context.app.host.name) {
    //         case 'Office': // running in Office
    //           environmentMessage = this.context.isServedFromLocalhost ? strings.AppLocalEnvironmentOffice : strings.AppOfficeEnvironment;
    //           break;
    //         case 'Outlook': // running in Outlook
    //           environmentMessage = this.context.isServedFromLocalhost ? strings.AppLocalEnvironmentOutlook : strings.AppOutlookEnvironment;
    //           break;
    //         case 'Teams': // running in Teams
    //         case 'TeamsModern':
    //           environmentMessage = this.context.isServedFromLocalhost ? strings.AppLocalEnvironmentTeams : strings.AppTeamsTabEnvironment;
    //           break;
    //         default:
    //           environmentMessage = strings.UnknownEnvironment;
    //       }

    //       return environmentMessage;
    //     });
    // }

    return Promise.resolve(this.context.isServedFromLocalhost ? strings.AppLocalEnvironmentSharePoint : strings.AppSharePointEnvironment);
  }

Once I redeploy, here is the web part on iOS in the Teams app:
image

Can you check to see if we have the same version of TeamsJS being handed to us? Thanks

@AJIXuMuK
Copy link
Collaborator

@thechriskent I'm testing on Prod so should be on the same version.
And double checked that 2.24.0 is used in my case as well.
Have you tried on another tenant?
Also could you try modifying the code to have catch block and see if any error is presented?

@thechriskent
Copy link
Collaborator Author

thechriskent commented Sep 19, 2024

Everything works as expected in my dev tenant (teamsJs 2.24.0) and since it's working for you, I'm assuming it's something specific to our corporate tenant. I'd also guess the teamsJs version isn't likely the problem but rather whatever is hot swapping the dependency.

Trying to troubleshoot what the problem is, however, is proving to be super hard. Wrapping the call in a try/catch fixes nothing. Unless I comment out the call to teamsJs.app.getContext() entirely, the bundle does not load. Even if that code is unreachable, just it existing in the project causes the web part to not load in teams mobile (within our tenant).

So, the problem appears to only be affecting my tenant (that we know of). However, the issue showed up in previously working already deployed code, can be recreated with the vanilla setup, and the error is happening before my code even loads. This strongly appears to be a Microsoft issue. Seeing as we are on a few rings ahead of targeted release, I wouldn't be surprised to see this issue start showing up more widely (though I don't know how many SPFx webparts are being surfaced in Teams on mobile). With that in mind, if anyone is aware of any teams/tenant settings that we might have enabled that could cause this, I'm all ears.

Should I open a true support ticket for this one?


As an aside, what is the reasoning for how teamsJS is handled compared to other dependencies? This seems super weird that although I have a dependency specified and can test with it, the hot swap nature of it makes our testing invalid, causes issues with mismatched typings, and introduces a dependency we don't actually have control over and can only validate at runtime.

I'm not aware of any other part of SPFx doing that. Who thought this was a good idea?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:spfx Category: SharePoint Framework (not extensions related) area:spfx-msteams Category: SharePoint Framework & Microsoft Teams support Needs: Author Feedback Awaiting response from the original poster of the issue. Marked as stale if no activity for 7 days. type:bug-suspected Suspected bug (not working as designed/expected). See “type:bug-confirmed” for confirmed bugs.
Projects
None yet
Development

No branches or pull requests

3 participants