Refactor the JobRunner to use actors and be async/await#538
Merged
mpretty-cyro merged 27 commits intosession-foundation:devfrom Feb 2, 2026
Merged
Conversation
• Refactored the JobRunner • Refactored the JobQueue • Refactored the FailedAttachmentDownloadsJob to be async/await • Refactored the FailedMessageSendsJob to be async/await • Removed the `uniqueHashValue` from `Job` (make the `shouldBeUnique` behaviour part of the `DisplayPictureDownloadJob` instead)
…efactor # Conflicts: # Session.xcodeproj/project.pbxproj # Session/Settings/NukeDataModal.swift # SessionMessagingKit/Jobs/AttachmentDownloadJob.swift # SessionMessagingKit/Jobs/AttachmentUploadJob.swift # SessionMessagingKit/Jobs/CheckForAppUpdatesJob.swift # SessionMessagingKit/Jobs/ConfigurationSyncJob.swift # SessionMessagingKit/Jobs/DisplayPictureDownloadJob.swift # SessionMessagingKit/Jobs/ExpirationUpdateJob.swift # SessionMessagingKit/Jobs/GroupInviteMemberJob.swift # SessionMessagingKit/Jobs/MessageReceiveJob.swift # SessionMessagingKit/Jobs/SendReadReceiptsJob.swift # SessionMessagingKit/Jobs/UpdateProfilePictureJob.swift # SessionMessagingKit/Utilities/Profile+CurrentUser.swift # SessionUtilitiesKit/JobRunner/JobRunner.swift # SessionUtilitiesKit/Types/CurrentValueAsyncStream.swift
• Updated `waitUntilInitialised` to have fallback support for iOS 15 • Updated the JobExecutor to allow individual jobs to control their concurrent execution behaviour • Fixed some race conditions in the JobRunner • Fixed some issues with concurrent job running • Fixed some issues where jobs would initialise a Noop version of libSession which could break the users state during this app run
• Updated the code to set the `JobPriorityContext` when entering/leaving a conversation • Updated the MessageReceiveJob to split failed messages into a separate job (keeps the behaviours and logs more consistent) • Updated the Onboarding code to use async/await instead of publishers • Updated the BackgroundPoller to handle the async/await Poller changes • Fixed a couple of issues with the file download sorting • Fixed an issue when setting the file sort data retriever • Fixed an issue where "initial job dependencies" provided when adding a job to the job runner weren't saved to the database • Fixed a few issues where jobs could fail or behave strangely on startup because they were racing initial data loading • Fixed an issue where the home and conversation screens would try to trigger layouts while the app was doing background fetches
• Added a timeout to the background message sending logic
• Updated the logic to allow starting specific job variants during the background period (so dependant jobs work)
• Updated the job filtering logic to allow OR based filters within a category (eg. select jobs where "RUNNING" AND ("messageSend" OR "attachmentUpload")
RyanRory
reviewed
Jan 27, 2026
RyanRory
reviewed
Jan 28, 2026
RyanRory
reviewed
Jan 28, 2026
RyanRory
reviewed
Jan 28, 2026
RyanRory
reviewed
Jan 28, 2026
RyanRory
approved these changes
Jan 28, 2026
• Made some optimisations to the logging logic • Updated a bunch of group update functions to be async/await • Updated code to use `decodedMessage.sender` everywhere instead of `message.sender` (where available) • Fixed an issue where we would pointlessly try to mutate the contacts config when updating the current users profile info • Fixed an issue where onboarding could fail to save the user to the database due to a query trying to update a non-existent config
• Cleaned up some logic and updated some database actions to be bulk actions • Fixed an issue where a long running blocking startup job could lockup the JobRunner preventing any calls to it from returning • Fixed an issue where jobs being added with initial dependencies could incorrectly be started before the dependencies we added • Fixed a painful race condition which could cause odd job running behaviours with dependencies due to async loop logic • Fixed a race condition where a "ghost" dependency could be added to a job if it was removed while being read from the database
…it wasn't removed
• Fixed an issue where the home and conversation screens wouldn't update if a system prompt was visible • Fixed an issue where receiving a new conversation may not update the home screen under some circumstances
…imations were disabled
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.
ThreadSafelogic from bothuniqueHashValuefromJobshouldBeUniquebehaviour part of theDisplayPictureDownloadJob(since it's only used for that one job)JobExecuterstructure (a number of these will need further refactoring to be fully async/await)