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

Bugfix FXIOS-7871 [v125] Opening a link in external app leaves a "loading" about:blank page behind #19288

Conversation

dicarobinho
Copy link
Collaborator

@dicarobinho dicarobinho commented Mar 19, 2024

📜 Tickets

Jira ticket
Github issue

💡 Description

Verify if an app like Youtube is installed and open it when a link (e.g. Youtube link) is accessed.

Based on the issue description and comments, I added in the apps list (LSApplicationQueriesSchemes), Youtube, Instagram and PayPal.

📝 Checklist

You have to check all boxes before merging

  • Filled in the above information (tickets numbers and description of your work)
  • Updated the PR name to follow our PR naming guidelines
  • Wrote unit tests and/or ensured the tests suite is passing
  • When working on UI, I checked and implemented accessibility (minimum Dynamic Text and VoiceOver)
  • If needed, I updated documentation / comments for complex code and public methods
  • If needed, added a backport comment (example @Mergifyio backport release/v120)

@dicarobinho dicarobinho marked this pull request as ready for review March 19, 2024 09:20
@dicarobinho dicarobinho requested a review from a team as a code owner March 19, 2024 09:20
@dicarobinho dicarobinho requested a review from cyndichin March 19, 2024 09:20
@cyndichin cyndichin requested review from mattreaganmozilla and removed request for cyndichin March 19, 2024 12:34
@mattreaganmozilla
Copy link
Collaborator

cc @nbhasin2 @OrlaM

Comment on lines +58 to +60
<string>paypal</string>
<string>instagram</string>
<string>youtube</string>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a bit confused: this might work for these specific URL schemes but there is a wide variety of schemes for other apps, wouldn't they also suffer from a similar problem?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, you right but this is the way that we can find if an app is installed or not. This apps should be manually added in this list and yea... may be other apps too.

Comment on lines +36 to +39
if navigationAction.canOpenExternalApp, let url = navigationAction.request.url {
UIApplication.shared.open(url)
return nil
}
Copy link
Collaborator

@mattreaganmozilla mattreaganmozilla Mar 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this basically a similar fix to what was implemented for whatsapp? e.g.:

   if url.scheme == "whatsapp" && UIApplication.shared.canOpenURL(url) {
                UIApplication.shared.open(url, options: [:])
            }

If so I'm just curious why we're not handling this in the same way? (*To clarify, what I mean is that the code for whatsapp and the paypal/YT/insta links seems to be applying a similar fix at first glance, but the code is slightly different, but it seems like all of these could be consolidated. LMK if I'm overlooking something though)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It may look the same but is a little bit different...

(few code for reference)

guard !navigationAction.isInternalUnprivileged,
             shouldRequestBeOpenedAsPopup(navigationAction.request)
       else {
           guard let url = navigationAction.request.url else { return nil }

           if url.scheme == "whatsapp" && UIApplication.shared.canOpenURL(url) {
               UIApplication.shared.open(url, options: [:])
           }

           return nil
       }

For other apps than "whatsapp" like "youtube" or "instagram", "shouldRequestBeOpenedAsPopup" method returns true because "url.scheme" is https not "youtube" or "instagram" as on "whatsapp" case. (based on the code, from above)

In this case, the logic, may be a little bit different.

@mattreaganmozilla
Copy link
Collaborator

Going to close and re-open to trigger Bitrise

@mobiletest-ci-bot
Copy link

Messages
📖 Project coverage: 33.75%
📖 Edited 2 files
📖 Created 0 files

Client.app: Coverage: 32.46

File Coverage
BrowserViewController+WebViewDelegates.swift 1.74% ⚠️

Generated by 🚫 Danger Swift against fe0ee22

Copy link
Collaborator

@mattreaganmozilla mattreaganmozilla left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe I understand the intent of the fix and it's nice that we can work around the about:blank page 👍 . I'm a bit confused though because it appears to require us to whitelist every scheme/app that we want to fix the bug for. So while this might fix PayPal/YouTube etc there are many other apps that will still suffer from the same problem (AFAIU). I see that the ticket mentions:

I do NOT see this in Safari. 
I DO see a similar behavior in Chrome

So it sounds like this isn't unique to Firefox, but I would've expected Apple to provide some kind of (more elegant) solution to this. 🤔

Change looks OK to me, though it would be nice if we could get additional 👀 on this from folks familiar with our deeplinking. (Maybe @PARAIPAN9 or @nbhasin2 ?)

@nbhasin2
Copy link
Contributor

@mattreaganmozilla BR is green, can we merge this?

Alex, doesn't have merge capabilities.

@mattreaganmozilla
Copy link
Collaborator

@mattreaganmozilla BR is green, can we merge this?

@nbhasin2 Yes I was planning to merge I was just hoping to get some additional eyes from folks familiar with deeplinking (maybe Sorin). But fine with me to merge now if needed.

@mattreaganmozilla mattreaganmozilla merged commit 85cebaa into mozilla-mobile:main Mar 20, 2024
10 of 11 checks passed
@OrlaM
Copy link
Contributor

OrlaM commented Mar 21, 2024

@Mergifyio backport release/124 release/125

Copy link
Contributor

mergify bot commented Mar 21, 2024

backport release/124 release/125

❌ No backport have been created

  • Backport to branch release/124 failed

GitHub error: Branch not found

  • Backport to branch release/125 failed

GitHub error: Branch not found

@OrlaM
Copy link
Contributor

OrlaM commented Mar 21, 2024

@Mergifyio release/v124 release/v125

Copy link
Contributor

mergify bot commented Mar 21, 2024

release /v124 release/v125

❌ Sorry but I didn't understand the command. Please consult the commands documentation 📚.

@OrlaM
Copy link
Contributor

OrlaM commented Mar 21, 2024

@Mergifyio backport release/v124 release/v125

Copy link
Contributor

mergify bot commented Mar 21, 2024

backport release/v124 release/v125

✅ Backports have been created

mergify bot pushed a commit that referenced this pull request Mar 21, 2024
… about:blank page behind (#19288)

Co-authored-by: Alexandru Farcasanu <c_afarcasanu@groupon.com>
(cherry picked from commit 85cebaa)
mergify bot pushed a commit that referenced this pull request Mar 21, 2024
… about:blank page behind (#19288)

Co-authored-by: Alexandru Farcasanu <c_afarcasanu@groupon.com>
(cherry picked from commit 85cebaa)
OrlaM pushed a commit that referenced this pull request Mar 22, 2024
… about:blank page behind (#19288) (#19339)

Co-authored-by: Alexandru Farcasanu <c_afarcasanu@groupon.com>
(cherry picked from commit 85cebaa)

Co-authored-by: dicarobinho <61138287+dicarobinho@users.noreply.github.com>
dsmithpadilla pushed a commit that referenced this pull request Mar 25, 2024
… about:blank page behind (#19288) (#19338)

Co-authored-by: Alexandru Farcasanu <c_afarcasanu@groupon.com>
(cherry picked from commit 85cebaa)

Co-authored-by: dicarobinho <61138287+dicarobinho@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants