Repository navigation
Conversation
Collaborator
Generated by 🚫 Danger |
Contributor
|
| App Name | Jetpack | |
| Configuration | Release-Alpha | |
| Build Number | 34853 | |
| Version | PR #26121 | |
| Bundle ID | com.jetpack.alpha | |
| Commit | f02c27a | |
| Installation URL | 5umv7bpdgot40 |
Contributor
|
| App Name | WordPress | |
| Configuration | Release-Alpha | |
| Build Number | 34853 | |
| Version | PR #26121 | |
| Bundle ID | org.wordpress.alpha | |
| Commit | f02c27a | |
| Installation URL | 1dm2fvep0thkg |
Signing in fetches the account's sites and then each site's Jetpack capabilities, and isn't finished until they arrive. They were handed back on the background queue, which the system serves last: while the device is busy it can leave that work unstarted, and even on an idle one the hop costs seconds. Measured from launch to My Site's first request, signing in with a token against fixtures on a Simulator: - Idle Mac: 6.4 and 7.1 seconds before, 3.3 after. - Every core busy: not in two minutes before, 3.2 to 3.5 seconds after. On CI this is what kept the first test of a UI test job on the sign-in screen for over 76 seconds: its Simulator had only just booted and was still busy. The new test fails with the background queue, where the callback runs at QOS_CLASS_BACKGROUND.
jkmassel
force-pushed
the
jkmassel/fix-urlsession-lazy-race
branch
from
October 7, 2026 02:26
c61446f to
af2b3a2
Compare
jkmassel
force-pushed
the
jkmassel/fix-capabilities-callback-priority
branch
from
October 7, 2026 02:26
3b2d9a8 to
f02c27a
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Fixes sign-in staying on the login screen for seconds longer than it needs to, and for as long as the device is busy with anything else, because the last thing it waits for was handed back on the background queue.
Stacked on #26116 so that #26119 can sit on top of both. The two fixes don't depend on each other.
Root cause
Signing in fetches the account's sites, then each site's Jetpack capabilities, and isn't finished until the capabilities arrive:
BlogService.syncBlogsForAccount→JetpackCapabilitiesService.sync→JetpackCapabilitiesServiceRemote.for(siteIds:). That last method gathers the responses with aDispatchGroupand called back withnotify(queue: .global(qos: .background)).The system serves the background queue last. While anything else wants the CPU it can leave that work unstarted, and even on an idle device the hop costs seconds. A sample of the app while it sat on the login screen showed the main thread idle and two dispatch worker threads that had been created and hadn't run an instruction.
The same callback also gates every later refresh of the account's sites, and of one site's details (
BlogService.blogDetailsHandler).Fix
Call back on the default-priority global queue.
Measurements
Time from launch to My Site's first request, signing in with a token on an iPhone 18 Pro simulator (iOS 27.0) with every response served locally, so that nothing but the app is being timed. Measured on #26119's branch, which has the token sign-in and the HTTP fixtures this needs.
yes > /dev/null)In both "before" rows the sites and their capabilities had all been answered about 3 seconds after launch. The rest was the wait for the callback.
This is what failed the first UI test in 5 of 10 CI jobs on #26119: the Simulator had only just booted and was still busy, and the app was on the login screen 76 seconds after launch with every request answered.
Test plan
testCapabilitiesAreNotDeliveredAtBackgroundPriorityfails without the fix, withXCTAssertNotEqual failed: ("qos_class_t(rawValue: 9)") is equal to ("qos_class_t(rawValue: 9)"), where 9 isQOS_CLASS_BACKGROUND. With the fix it passes, along with the other two tests inJetpackCapabilitiesServiceRemoteTests.