Skip to content

Liquid Glass and Apple Music touches for the Spotify iOS app. A GPL-3.0 fork of spoti.pw 0.21.1.

C

fix: a stuck Live Activity update no longer freezes the card

My-Name-Is-Jeff12159583b309
diff --git a/tweak/Sources/Shared/LiveActivity/LiveActivityBridge.swift b/tweak/Sources/Shared/LiveActivity/LiveActivityBridge.swift
index ec075daf..b0b49374 100644
--- a/tweak/Sources/Shared/LiveActivity/LiveActivityBridge.swift
+++ b/tweak/Sources/Shared/LiveActivity/LiveActivityBridge.swift
@@ -36,8 +36,13 @@ public final class SGLiveActivityBridge: NSObject {
private struct Pending: Sendable {
var changes: [Change] = []
var sending = false
+ // When the change being sent went out. One ActivityKit never answers would otherwise hold every
+ // later change behind it and freeze the card; past kStuckAfter a new sender takes over.
+ var sentAt: Date?
}
+ private static let kStuckAfter: TimeInterval = 5
+
private static let pending = OSAllocatedUnfairLock(initialState: Pending())
private static func queue(_ change: Change) {
@@ -46,8 +51,10 @@ public final class SGLiveActivityBridge: NSObject {
pending.changes.removeLast()
}
pending.changes.append(change)
- if pending.sending { return false }
+ if pending.sending, let at = pending.sentAt, Date().timeIntervalSince(at) < kStuckAfter { return false }
+ if pending.sending { log.notice("[spotifyglass] live activity: an update has not landed in \(kStuckAfter, privacy: .public) s, sending on past it") }
pending.sending = true
+ pending.sentAt = nil
return true
}
if start { Task { await send() } }
@@ -57,8 +64,10 @@ public final class SGLiveActivityBridge: NSObject {
while let change = pending.withLock({ pending -> Change? in
if pending.changes.isEmpty {
pending.sending = false
+ pending.sentAt = nil
return nil
}
+ pending.sentAt = Date()
return pending.changes.removeFirst()
}) {
switch change {
diff --git a/tweak/Sources/Shared/Sing/Sing.x b/tweak/Sources/Shared/Sing/Sing.x
index 4de33c01..a2cbce13 100644
--- a/tweak/Sources/Shared/Sing/Sing.x
+++ b/tweak/Sources/Shared/Sing/Sing.x
@@ -18,7 +18,8 @@
// before the last one ended: something new was played.
//
// The model is held only while the mic is on, and loaded on a queue of its own. From the thermal state
-// Serious on, the engine is held and plays dry, unless Ignore heat warnings is on.
+// At Critical the engine is held and plays dry, unless Ignore heat warnings is on. Serious is where a
+// charging iPhone sits for hours, and iOS itself only throttles hard at Critical.
//
// Spatial voice listens to Shared/HeadGestures' motion (the app's one CMHeadphoneMotionManager) while Sing is
// on and Spotify plays, and hands the engine the head's yaw off a front that follows where the head points over
@@ -473,7 +474,7 @@ static void watch(void) {
#pragma mark - the heat
static void readHeat(void) {
- BOOL hot = NSProcessInfo.processInfo.thermalState >= NSProcessInfoThermalStateSerious;
+ BOOL hot = NSProcessInfo.processInfo.thermalState >= NSProcessInfoThermalStateCritical;
if (hot == sg_hot) return;
sg_hot = hot;
SGLog(@"sing: the iPhone is %@%@", hot ? @"hot" : @"cool again", hot && SGHidden(SGKeySingIgnoreHeat) ? @", and heat warnings are ignored" : @"");