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

Add SYNC-3478 [v109] Poll for missing send tabs on interval #12377

Merged
merged 3 commits into from
Nov 25, 2022

Conversation

tarikeshaq
Copy link
Contributor

@tarikeshaq tarikeshaq commented Nov 14, 2022

On desktop and android, we poll for missed send tabs occasionally. For iOS, we only poll for send tabs when we receive a notification (and even then, we only poll for exactly one tab). This PR changes it so we poll for missing commands whenever we sync the clients collection.

Happy to take any feedback here. Creating the PR as a starting point. Keeping as a draft as I do more testing on a physical device

Questions:

What's the user experience:

  • I'll upload a small gif recording, but its:
    • Once the browser detects that there are missing tabs, it would open and switch to them

Would this increase load to the FxA servers

  • Yes, but now we are mimicking Firefox Desktop, so the load on FxA shouldn't be dramatically impacted
    • We will poll once a day on a scheduled sync
    • We will poll on sync now
    • We will poll when we detect that our FxA push endpoint has expired

Now that we poll, what happens to users who didn't get their tabs in the past?

  • Each send tab has a TTL of 30 days. Users will get all the tabs they sent and lost in past 30 days, but they won't get anymore.
  • That said, I'm happy to make the first poll a noop, so we silently drop tabs that could have been sent before this so that we don't surprise users.

@tarikeshaq tarikeshaq force-pushed the poll-commands-on-interval branch 3 times, most recently from d24eec2 to 4a4246b Compare November 21, 2022 21:34
@tarikeshaq tarikeshaq force-pushed the poll-commands-on-interval branch from 4a4246b to e7755ba Compare November 21, 2022 21:36
@tarikeshaq tarikeshaq changed the title Add SYNC-3478 [v109] Poll for missing send tabs when syncing clients Add SYNC-3478 [v109] Poll for missing send tabs on interval Nov 21, 2022
@tarikeshaq tarikeshaq marked this pull request as ready for review November 21, 2022 21:41
@tarikeshaq
Copy link
Contributor Author

tarikeshaq commented Nov 21, 2022

Going to add a test for pollCommands but this should be ready for review - I'll also do some testing on a physical device, since this PR also changes the push notification handling

Copy link
Contributor

@OrlaM OrlaM left a comment

Choose a reason for hiding this comment

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

A small nit if you feel like changing it, otherwise LGTM.

Account/FxAPushMessageHandler.swift Outdated Show resolved Hide resolved
@tarikeshaq tarikeshaq force-pushed the poll-commands-on-interval branch from 83478a6 to 764b520 Compare November 24, 2022 00:02
Copy link
Contributor Author

@tarikeshaq tarikeshaq left a comment

Choose a reason for hiding this comment

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

Thanks a ton for the review @OrlaM 🙏 I added one more commit after doing testing on my physical device

Unfortunately couldn't find any testing infra for BrowserProfile so testing pollCommands properly seemed more trouble than its worth

If it looks good, I would love to see this land (I don't have permission to land PRs 😞)

// Reconfig has to happen on the main thread, since it calls `startup`
// and `startup` asserts that we are on the main thread. Otherwise the notification
// service will crash.
DispatchQueue.main.async {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm mildly surprised send tab even works in prod correctly. I had to add this because my device couldn't receive send tabs properly, and after debugging I found that the culprit is that the NotificationService on my device is running a background thread when receiving messages

This causes it to crash and deliver a default notification instead of the actual tab

I'm assuming in production builds (and in beta I tested to make sure) the notification service runs on the main thread somehow? regardless dispatching this onto the main thread fixed local push notification for me on my iPhone

@tarikeshaq
Copy link
Contributor Author

Let’s hold off on merging this while I confirm one more thing! Tapping on a push notification while the app is backgrounded is not launching the tab - I’ll flag once I figure out what’s going there

@OrlaM
Copy link
Contributor

OrlaM commented Nov 24, 2022

Might be worth checking if that actually works on main. We made the switch to use SceneDelegates recently which has caused a few deeplinking bugs to pop up, so might not be caused by your PR.

@tarikeshaq
Copy link
Contributor Author

Rebased on main the problem fixed itself! This should be good to land, with an enhancement coming soon in the next application-services release. Currently, if we get a push notification and we poll soon after, it's possible that the poll would reopen the same tab again

This is possible if the account manager didn't refresh its state before the next poll, since the notification service has its own instance of the account manager.

I'll have a PR next week with a new AS release to make it impossible

@OrlaM OrlaM merged commit 6240fdf into mozilla-mobile:main Nov 25, 2022
@tarikeshaq tarikeshaq deleted the poll-commands-on-interval branch November 25, 2022 16:27
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.

2 participants