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

chore: the player menu and Karaoke log why they wait

My-Name-Is-Jeffb6d86f425e69
diff --git a/tweak/Sources/Redesigned/ContextMenu/ContextMenu.x b/tweak/Sources/Redesigned/ContextMenu/ContextMenu.x
index 782c0c5f..2cd11cc6 100644
--- a/tweak/Sources/Redesigned/ContextMenu/ContextMenu.x
+++ b/tweak/Sources/Redesigned/ContextMenu/ContextMenu.x
@@ -625,10 +625,14 @@ BOOL SGPlayerMenuReplaced(UIViewController *menu) {
if (press.state != UIGestureRecognizerStateBegan) return;
sg_claimButton = press.view;
sg_claimAt = CACurrentMediaTime();
+ static int logged;
+ if (logged++ < 3) SGLog(@"system menu: ⋯ pressed (%@)", NSStringFromClass(press.view.class));
}
- (void)touchedDown:(UIView *)control {
sg_claimButton = control;
sg_claimAt = CACurrentMediaTime();
+ static int logged;
+ if (logged++ < 3) SGLog(@"system menu: ⋯ touched down (%@)", NSStringFromClass(control.class));
}
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)recognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)other {
return YES;
@@ -643,6 +647,9 @@ void SGRSystemMenuWatch(UIView *button, SGRMenuItems items, SGRMenuKind kind) {
static SGRMenuTapWatcher *watcher;
if (!watcher) watcher = [SGRMenuTapWatcher new];
objc_setAssociatedObject(button, &kWatchedKey, @YES, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
+ static int logged;
+ if (logged++ < 4) SGLog(@"system menu: watching a ⋯ (%@, %@ touches, in %@)", NSStringFromClass(button.class),
+ button.userInteractionEnabled ? @"takes" : @"takes no", NSStringFromClass(button.superview.class));
// An Encore button may read its touches through a gesture recognizer rather than as a control, so both
// are watched.
if ([button isKindOfClass:UIControl.class]) [(UIControl *)button addTarget:watcher action:@selector(touchedDown:) forControlEvents:UIControlEventTouchDown];
@@ -673,6 +680,11 @@ static SGRMenuAnchor *anchorIn(UIView *host) {
}
// Whether this sheet is a watched ⋯'s, and if so its session, with the sheet's presentation now the menu's.
+static void whyNot(NSString *reason) {
+ static int logged;
+ if (logged++ < 8) SGLog(@"system menu: not taken over: %@", reason);
+}
+
static SGRMenuSession *takeOver(UIViewController *presented) {
if (!sheetIn(presented)) return nil;
UIView *button = nil;
@@ -682,7 +694,10 @@ static SGRMenuSession *takeOver(UIViewController *presented) {
} else {
button = SGRPinnedMoreRecentButton();
}
- if (!button.window) return nil;
+ if (!button.window) {
+ whyNot(button ? @"the claimed ⋯ is off screen" : sg_claimButton ? [NSString stringWithFormat:@"the claim is %.1f s old", CACurrentMediaTime() - sg_claimAt] : @"no ⋯ was claimed");
+ return nil;
+ }
static BOOL canPresent, checked;
if (!checked) {
checked = YES;
@@ -722,6 +737,8 @@ static SGRMenuSession *takeOver(UIViewController *presented) {
// taken over here instead, from the same claim, and its menu opened once it has appeared.
- (void)viewWillAppear:(BOOL)animated {
%orig;
+ static int logged;
+ if (logged++ < 3) SGLog(@"system menu: a ⋯ sheet will appear (%@ session)", sessionFor((UIViewController *)self) ? @"with a" : @"without a");
SGRMenuSession *session = sessionFor((UIViewController *)self);
if (!session && (session = takeOver((UIViewController *)self))) {
static int logged;
diff --git a/tweak/Sources/Shared/Sing/Sing.x b/tweak/Sources/Shared/Sing/Sing.x
index 560803b8..4de33c01 100644
--- a/tweak/Sources/Shared/Sing/Sing.x
+++ b/tweak/Sources/Shared/Sing/Sing.x
@@ -129,11 +129,12 @@ static dispatch_queue_t loadQueue(void) {
return queue;
}
+// The Neural Engine unless changed: on an iPhone 15 Pro the GPU never finished its first load of this model.
static MLComputeUnits computeUnits(void) {
- switch (SGInt(SGKeySingComputeUnits, 0)) {
+ switch (SGInt(SGKeySingComputeUnits, 2)) {
+ case 0: return MLComputeUnitsCPUAndGPU;
case 1: return MLComputeUnitsAll;
- case 2: return MLComputeUnitsCPUAndNeuralEngine;
- default: return MLComputeUnitsCPUAndGPU;
+ default: return MLComputeUnitsCPUAndNeuralEngine;
}
}
@@ -144,7 +145,17 @@ static void loadModel(void) {
sg_loadError = nil;
NSUInteger generation = sg_loadGeneration;
MLComputeUnits units = computeUnits();
- SGLog(@"sing: loading the voice model");
+ SGLog(@"sing: loading the voice model on the %@", SGSingComputeUnitNames()[(NSUInteger)MIN(MAX(SGInt(SGKeySingComputeUnits, 2), 0), 2)]);
+ // A load that takes long says so, so a stall reads apart from a slow first compile.
+ __block void (^still)(int) = nil;
+ still = ^(int seconds) {
+ dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 30 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{
+ if (!sg_loading || generation != sg_loadGeneration) { still = nil; return; }
+ SGLog(@"sing: still loading the voice model, %d s", seconds + 30);
+ still(seconds + 30);
+ });
+ };
+ still(0);
dispatch_async(loadQueue(), ^{
CFAbsoluteTime began = CFAbsoluteTimeGetCurrent();
MLModelConfiguration *configuration = [MLModelConfiguration new];
diff --git a/tweak/Sources/Shared/Sing/SingSettings.m b/tweak/Sources/Shared/Sing/SingSettings.m
index d2de5c40..cee68ba1 100644
--- a/tweak/Sources/Shared/Sing/SingSettings.m
+++ b/tweak/Sources/Shared/Sing/SingSettings.m
@@ -126,7 +126,7 @@ UIViewController *SGSingSettingsPage(void) {
spatial.visible = ^BOOL { return SGSingSpatialAvailable(); };
__block __weak SGModPage *page;
SGModRow *model = SGStatActionRow(@"Voice model", @"Mel-Band RoFormer, run on the iPhone", ^NSString *{ return modelValue(); }, ^{ modelTapped(page); });
- SGModRow *units = SGChoiceRow(@"Runs on", @"Read as the model loads", SGKeySingComputeUnits, SGSingComputeUnitNames(), 0);
+ SGModRow *units = SGChoiceRow(@"Runs on", @"Read as the model loads", SGKeySingComputeUnits, SGSingComputeUnitNames(), 2);
units.chosen = ^(NSInteger index) { SGSingComputeUnitsChanged(); };
SGModRow *heat = SGOptionRow(@"Ignore heat warnings", @"Keeps Sing going on a hot iPhone, which then gets hotter", SGKeySingIgnoreHeat);
heat.changed = ^(BOOL on) { SGSetSingIgnoresHeat(on); };