Skip to content

Remove long-unused Iterable deep links handling #24487

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

Open
wants to merge 2 commits into
base: trunk
Choose a base branch
from

Conversation

mokagio
Copy link
Contributor

@mokagio mokagio commented Apr 22, 2025

See pbMoDN-fd-p2#comment-7311 , with thanks to @crazytonyli for noticing this.

I'm still waiting for confirmation from the marketing folks that the unused assumption is correct, but I'm fairly confident it is, so in the meantime I went ahead and opened this quick PR.

For reference, Iterable support was introduced in #14212

This PR relates to https://linear.app/a8c/issue/CMM-260/configure-reader-target

I tested this using the same deep link URL suggested in #14212 from Jetpack.

image

Notice two warnings in the console that we might want to look into later:

  • Presenting view controller <UINavigationController: 0x3222d8c00> from detached view controller <WordPress.NotificationsViewController: 0x32383ea00> is not supported, and may result in incorrect safe area insets and a corrupt root presentation. Make sure <WordPress.NotificationsViewController: 0x32383ea00> is in the view controller hierarchy before presenting from it. Will become a hard exception in a future release.
  • Background Task 57 ("Called by Jetpack.debug.dylib, from $s9WordPress0aB11AppDelegateC29applicationDidEnterBackgroundyySo13UIApplicationCFTo"), was created over 30 seconds ago. In applications running in the background, this creates a risk of termination. Remember to call UIApplication.endBackgroundTask(_:) for your task in a timely manner to avoid this.

@dangermattic
Copy link
Collaborator

1 Message
📖 This PR is still a Draft: some checks will be skipped.

Generated by 🚫 Danger

Base automatically changed from mokagio/reader-secerts-and-config-update to trunk April 22, 2025 05:51
@wpmobilebot
Copy link
Contributor

wpmobilebot commented Apr 22, 2025

App Icon📲 You can test the changes from this Pull Request in WordPress by scanning the QR code below to install the corresponding build.
App NameWordPress
ConfigurationRelease-Alpha
Build Number27446
VersionPR #24487
Bundle IDorg.wordpress.alpha
Commit6f001c4
Installation URL57a9ihl8o0q4g
Automatticians: You can use our internal self-serve MC tool to give yourself access to those builds if needed.

@wpmobilebot
Copy link
Contributor

wpmobilebot commented Apr 22, 2025

App Icon📲 You can test the changes from this Pull Request in Jetpack by scanning the QR code below to install the corresponding build.
App NameJetpack
ConfigurationRelease-Alpha
Build Number27446
VersionPR #24487
Bundle IDcom.jetpack.alpha
Commit6f001c4
Installation URL297t1rs49nrao
Automatticians: You can use our internal self-serve MC tool to give yourself access to those builds if needed.

Comment on lines -25 to +31
self.selectedIndex = WPTab.notifications.rawValue
completion?(self.notificationsViewController!)
// UITabBarController.selectedIndex must be used from main thread only.
DispatchQueue.main.async { [weak self] in
guard let self else { return }

self.selectedIndex = WPTab.notifications.rawValue
completion?(self.notificationsViewController!)
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Noticed this when running Jetpack in the Simulator and opening the app simulating a user deep link via xcrun simctl openurl booted https://wordpress.com/notifications

image

I considered moving the main thread dispatch earlier on, e.g. in the deep link handling

diff --git a/WordPress/Classes/System/WordPressAppDelegate.swift b/WordPress/Classes/System/WordPressAppDelegate.swift
index 8167daf7b1..6b9a57642a 100644
--- a/WordPress/Classes/System/WordPressAppDelegate.swift
+++ b/WordPress/Classes/System/WordPressAppDelegate.swift
@@ -457,7 +457,9 @@ extension WordPressAppDelegate {
         }
 
         trackDeepLink(for: url) { url in
-            UniversalLinkRouter.shared.handle(url: url)
+            DispatchQueue.main.async {
+                UniversalLinkRouter.shared.handle(url: url)
+            }
         }
     }

but I thought it best to be precise and keep the main thread dispatching as close to the code requiring it as possible.

However, forcing the deep link handling to run on the main thread might be a good blanket approach if we fear that other deep link might implicitly require the main thread.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'd suggest adding DispatchQueue.main.async in trackDeepLink as you originally wanted and adding wpAssert(Thread.isMainThread) in showNotificationsTab. In the future, we'll try and use @MainActor as much as we can.

Adding an async in showNotificationsTab is too risky because it has many callers, and some of them might rely on it executing synchronously.

@mokagio mokagio force-pushed the mokagio/links-update branch from 292bb06 to 6f001c4 Compare April 22, 2025 06:11
@mokagio mokagio added this to the 26.1 milestone Apr 22, 2025
@mokagio mokagio self-assigned this Apr 22, 2025
@mokagio mokagio requested review from crazytonyli, kean and Copilot April 22, 2025 06:11
@mokagio mokagio marked this pull request as ready for review April 22, 2025 06:11
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR removes legacy deep link handling code related to Iterable and ensures that notification tab transitions occur on the main thread.

  • Removed the unused Iterable deep link check and related methods.
  • Updated notifications tab presentation to guarantee UI updates occur on the main thread.

Reviewed Changes

Copilot reviewed 2 out of 8 changed files in this pull request and generated no comments.

File Description
WordPress/Classes/System/WordPressAppDelegate.swift Removed Iterable-specific code and simplified deep link tracking logic.
WordPress/Classes/System/Root View/WPTabBarController+RootViewPresenter.swift Ensured notifications tab selection is executed on the main thread with DispatchQueue.main.
Files not reviewed (6)
  • Sources/Reader/Reader.entitlements: Language not supported
  • WordPress/Jetpack/JetpackDebug.entitlements: Language not supported
  • WordPress/Jetpack/JetpackRelease-Alpha.entitlements: Language not supported
  • WordPress/Jetpack/JetpackRelease.entitlements: Language not supported
  • WordPress/WordPress-Alpha.entitlements: Language not supported
  • WordPress/WordPress.entitlements: Language not supported
Comments suppressed due to low confidence (1)

WordPress/Classes/System/WordPressAppDelegate.swift:477

  • The URLSession data task does not call the completion handler if response?.url is nil, which could lead to unexpected behavior. Consider adding a fallback call to the completion handler (or an error callback) when the response URL is unavailable.
guard let url = response?.url else { return }

Comment on lines +477 to +481
guard let url = response?.url else {
return
}

completion(url)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copilot observed:

The URLSession data task does not call the completion handler if response?.url is nil, which could lead to unexpected behavior. Consider adding a fallback call to the completion handler (or an error callback) when the response URL is unavailable.

That's a good point actually. I don't think it's in scope for this PR, but we might want to log a ticket to look into it. Unless... how can we get to the point where a deep link has a response without URL? Is this a legacy from the Objective-C NSURLResponse implementation?

Copy link
Contributor

Choose a reason for hiding this comment

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

If you never expect it to happen, let's add wpAssertionFailure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants