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

feat: Karaoke can ignore memory warnings

My-Name-Is-Jeffe471bac2ac6a
diff --git a/tweak/Sources/Shared/Sing/Sing.h b/tweak/Sources/Shared/Sing/Sing.h
index 16d676ae..dfc0c56d 100644
--- a/tweak/Sources/Shared/Sing/Sing.h
+++ b/tweak/Sources/Shared/Sing/Sing.h
@@ -38,6 +38,9 @@ extern NSNotificationName const SGSingButtonDidChangeNotification;
#define SGKeySingLevel @"spotifyglass.sing.level"
// Keeps the model running on a hot iPhone, which otherwise lets it go from the thermal state Serious up.
#define SGKeySingIgnoreHeat @"spotifyglass.sing.ignoreHeat"
+// Keeps the model through iOS's memory warnings, which otherwise let it go and stop Karaoke until the next song.
+// Off until switched on: with it on, iOS may close Spotify instead.
+#define SGKeySingIgnoreMemory @"spotifyglass.sing.ignoreMemory"
// Where the model runs: an index into SGSingComputeUnitNames(), Automatic (0: a Neural Engine copy beside the CPU's,
// where the iPhone has a Neural Engine) unless CPU only (1) is chosen. The GPU, Neural Engine and GPU and Neural Engine
// stored before (2-4), and the earlier key's every value, are Automatic now, carried over at launch.
diff --git a/tweak/Sources/Shared/Sing/Sing.x b/tweak/Sources/Shared/Sing/Sing.x
index e78aee9b..3bd0ed95 100644
--- a/tweak/Sources/Shared/Sing/Sing.x
+++ b/tweak/Sources/Shared/Sing/Sing.x
@@ -1304,6 +1304,10 @@ static void readHeat(void) {
}];
// Low on memory, the model goes at once, before iOS closes Spotify for it.
[center addObserverForName:UIApplicationDidReceiveMemoryWarningNotification object:nil queue:NSOperationQueue.mainQueue usingBlock:^(NSNotification *note) {
+ if (SGHidden(SGKeySingIgnoreMemory)) {
+ SGLog(@"sing: iOS warned that memory is low; the model is kept (Ignore memory warnings)");
+ return;
+ }
SGSingLoaderPurge(@"iOS warned that memory is low");
// Over a stop for falling behind, which would load the model again with the next track whatever the memory.
if (!SGSingOn() || (sg_stopped && sg_stopKind != SGSingStopBehind)) return;
diff --git a/tweak/Sources/Shared/Sing/SingSettings.m b/tweak/Sources/Shared/Sing/SingSettings.m
index 1372312d..f33f7748 100644
--- a/tweak/Sources/Shared/Sing/SingSettings.m
+++ b/tweak/Sources/Shared/Sing/SingSettings.m
@@ -206,6 +206,8 @@ UIViewController *SGSingSettingsPage(void) {
button.changed = ^(BOOL on) { [NSNotificationCenter.defaultCenter postNotificationName:SGSingButtonDidChangeNotification object:nil]; };
button.visible = ^BOOL { return SGRedesignedUIStored(); };
SGModRow *heat = SGOptionRow(@"Ignore heat warnings", @"Keeps Karaoke going on a hot iPhone, which then gets hotter", SGKeySingIgnoreHeat);
+ SGModRow *memory = SGOptionRow(@"Ignore memory warnings", @"Keeps Karaoke going when iOS is low on memory, which may then close Spotify",
+ SGKeySingIgnoreMemory);
heat.changed = ^(BOOL on) { SGSetSingIgnoresHeat(on); };
__block __weak SGModPage *page;
SGModRow *model = SGStatActionRow(@"Voice model", nil, ^NSString *{ return modelValue(); }, ^{ modelTapped(page); });
@@ -238,7 +240,7 @@ UIViewController *SGSingSettingsPage(void) {
SGModRow *prepare = SGSwitchRow(@"Prepare after updates",
@"Readies the Neural Engine in the background after Vitrine or iOS updates, so Karaoke starts at full speed", SGKeySingPrepareAhead);
SGSingPage *made = [[SGSingPage alloc] initWithTitle:@"Karaoke" intro:nil sections:@[
- SGSection(nil, @[sing, button, heat, model, remove]),
+ SGSection(nil, @[sing, button, heat, memory, model, remove]),
SGSection(nil, @[spatial]),
SGNotedSection(@"Advanced", @[units, prepare],
@"Karaoke turns a song's vocals down to sing over, or the rest down to hear the vocals alone, with a voice model that "