mirror of
https://github.com/sparkle-project/Sparkle
synced 2026-11-25 04:47:55 +00:00
Critical update alerts may not show up as promptly as they should when automatically installing them (#2221)
Wait for appcast item registration before finishing automatic update driver. This fixes a potential race issue where sometimes the automatic update driver on completion would sometimes not trigger to prompt an update alert immediately for critical updates. Note in this case, the update would still be installed on app termination and would still be scheduled to alert the user on the regular update check interval, so this issue is not severe.
This commit is contained in:
6 files changed
+43
-7
No files matched your search
@@ -34,6 +34,7 @@
|
||||
|
||||
#define FIRST_UPDATER_MESSAGE_TIMEOUT 18ull
|
||||
#define RETRIEVE_PROCESS_IDENTIFIER_TIMEOUT 8ull
|
||||
#define UPDATER_APPCAST_ITEM_REGISTRATION_TIMEOUT 8ull
|
||||
|
||||
/**
|
||||
* Show display progress UI after a delay from starting the final part of the installation.
|
||||
@@ -425,7 +426,25 @@ static const NSTimeInterval SUDisplayProgressTimeDelay = 0.7;
|
||||
|
||||
NSData *archivedData = SPUArchiveRootObjectSecurely(installationInfo);
|
||||
if (archivedData != nil) {
|
||||
[self.agentConnection.agent registerInstallationInfoData:archivedData];
|
||||
__block BOOL notifiedRegistrationCompleted = NO;
|
||||
|
||||
[self.agentConnection.agent registerInstallationInfoData:archivedData completionHandler:^{
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
if (!notifiedRegistrationCompleted) {
|
||||
notifiedRegistrationCompleted = YES;
|
||||
[self.communicator handleMessageWithIdentifier:SPUInstallerRegisteredAppcastItem data:[NSData data]];
|
||||
}
|
||||
});
|
||||
}];
|
||||
|
||||
// Not receiving that we've registered the appcast item in a timely manner is not a fatal issue
|
||||
// If this operation takes too long, just let assume the item will be registered
|
||||
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(UPDATER_APPCAST_ITEM_REGISTRATION_TIMEOUT * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
||||
if (!notifiedRegistrationCompleted) {
|
||||
notifiedRegistrationCompleted = YES;
|
||||
[self.communicator handleMessageWithIdentifier:SPUInstallerRegisteredAppcastItem data:[NSData data]];
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
} else if (identifier == SPUResumeInstallationToStage2 && data.length == sizeof(uint8_t) * 2) {
|
||||
|
||||
@@ -23,7 +23,8 @@ typedef NS_ENUM(int32_t, SPUInstallerMessageType)
|
||||
SPUInstallationFinishedStage2 = 7,
|
||||
SPUInstallationFinishedStage3 = 8,
|
||||
SPUUpdaterAlivePing = 9,
|
||||
SPUInstallerError = 10
|
||||
SPUInstallerError = 10,
|
||||
SPUInstallerRegisteredAppcastItem = 11,
|
||||
};
|
||||
|
||||
typedef NS_ENUM(int32_t, SPUUpdaterMessageType)
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
|
||||
BOOL SPUInstallerMessageTypeIsLegal(SPUInstallerMessageType oldMessageType, SPUInstallerMessageType newMessageType)
|
||||
{
|
||||
BOOL legal;
|
||||
BOOL legal = NO;
|
||||
switch (newMessageType) {
|
||||
case SPUInstallerNotStarted:
|
||||
legal = (oldMessageType == SPUInstallerNotStarted);
|
||||
@@ -45,7 +45,7 @@ BOOL SPUInstallerMessageTypeIsLegal(SPUInstallerMessageType oldMessageType, SPUI
|
||||
legal = (oldMessageType == SPUInstallationStartedStage1);
|
||||
break;
|
||||
case SPUInstallationFinishedStage2:
|
||||
legal = (oldMessageType == SPUInstallationFinishedStage1);
|
||||
legal = (oldMessageType == SPUInstallationFinishedStage1 || oldMessageType == SPUInstallerRegisteredAppcastItem);
|
||||
break;
|
||||
case SPUInstallationFinishedStage3:
|
||||
legal = (oldMessageType == SPUInstallationFinishedStage2);
|
||||
@@ -56,6 +56,9 @@ BOOL SPUInstallerMessageTypeIsLegal(SPUInstallerMessageType oldMessageType, SPUI
|
||||
// So just always allow these type of messages
|
||||
legal = YES;
|
||||
break;
|
||||
case SPUInstallerRegisteredAppcastItem:
|
||||
legal = (oldMessageType == SPUInstallationFinishedStage1);
|
||||
break;
|
||||
}
|
||||
return legal;
|
||||
}
|
||||
|
||||
@@ -284,7 +284,7 @@ static const NSTimeInterval SUTerminationTimeDelay = 0.3;
|
||||
});
|
||||
}
|
||||
|
||||
- (void)registerInstallationInfoData:(NSData *)installationInfoData
|
||||
- (void)registerInstallationInfoData:(NSData *)installationInfoData completionHandler:(void (^)(void))completionHandler
|
||||
{
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
if (self.statusInfo.installationInfoData == nil && installationInfoData != nil) {
|
||||
@@ -297,6 +297,8 @@ static const NSTimeInterval SUTerminationTimeDelay = 0.3;
|
||||
SULog(SULogLevelError, @"Error: Failed to decode initial installation info from installer: %@", installationInfoData);
|
||||
}
|
||||
}
|
||||
|
||||
completionHandler();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -14,7 +14,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
- (void)registerApplicationBundlePath:(NSString *)applicationBundlePath reply:(void (^)(NSNumber * _Nullable processIdentifier))reply;
|
||||
|
||||
- (void)registerInstallationInfoData:(NSData *)installationInfoData;
|
||||
- (void)registerInstallationInfoData:(NSData *)installationInfoData completionHandler:(void (^)(void))completionHandler;
|
||||
|
||||
- (void)sendTerminationSignal;
|
||||
|
||||
|
||||
Vendored
+12
-1
@@ -66,6 +66,8 @@
|
||||
@implementation SPUInstallerDriver
|
||||
{
|
||||
void (^_updateWillInstallHandler)(void);
|
||||
BOOL _canInstallSilently;
|
||||
BOOL _hasTargetTerminated;
|
||||
}
|
||||
|
||||
@synthesize host = _host;
|
||||
@@ -327,7 +329,16 @@
|
||||
hasTargetTerminated = (BOOL)*((const uint8_t *)data.bytes + 1);
|
||||
}
|
||||
|
||||
[self.delegate installerDidFinishPreparationAndWillInstallImmediately:hasTargetTerminated silently:canInstallSilently];
|
||||
// The installer letting us know when the appcast item was registered (SPUInstallerRegisteredAppcastItem)
|
||||
// was added later. In earlier versions of Sparkle, we could have notified the update too early
|
||||
// before the installer finished registering the appcast item.
|
||||
// Note we don't need to handle an "old" installer because Sparkle and the installer should still be aligned at this point.
|
||||
_canInstallSilently = canInstallSilently;
|
||||
_hasTargetTerminated = hasTargetTerminated;
|
||||
} else if (identifier == SPUInstallerRegisteredAppcastItem) {
|
||||
self.currentStage = identifier;
|
||||
|
||||
[self.delegate installerDidFinishPreparationAndWillInstallImmediately:_hasTargetTerminated silently:_canInstallSilently];
|
||||
} else if (identifier == SPUInstallationFinishedStage2) {
|
||||
self.currentStage = identifier;
|
||||
|
||||
|
||||
Reference in new issue
Block a user