Skip to content

Commit 09fb1b4

Browse files
authored
Preview 1.82.4 (#759)
# What's changed? - **[Fix]** Re-introduce shared webp libraries on non-AOT builds, by @neon-nyan - **[Fix]** Avoid using long directory paths for ZZZ assets, by @neon-nyan - **[Fix]** Resolve taskbar progress being shown incorrectly during ZZZ game repair, by @neon-nyan - **[Imp]** Re-align subproject commits for main project (and update package-lock.json), by @bagusnl - **[New]** Prevent Windows from shutting down if a critical operation within Collapse is underway (update, install, repair), by @bagusnl, @neon-nyan - **[Fix]** Resolve an issue where a race condition could occur when loading a background, by @neon-nyan - **[Imp]** Introduce a delay if database communication fails for some reason, by @bagusnl
2 parents 8bc50e3 + 78ecc99 commit 09fb1b4

24 files changed

+282
-232
lines changed

CollapseLauncher.slnx

Lines changed: 54 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -6,80 +6,94 @@
66
<Platform Name="x64" />
77
</Configurations>
88
<Project Path="CollapseLauncher/CollapseLauncher.csproj">
9-
<Platform Project="x64" />
10-
<Deploy Solution="Release|*" />
9+
<Configuration Solution="Debug|x64" Project="Debug|x64" />
10+
<Configuration Solution="Release|x64" Project="Release|x64" />
1111
</Project>
1212
<Project Path="ColorThief/ColorThief/ColorThief.csproj">
13-
<BuildType Solution="Publish|*" Project="Release" />
14-
<Platform Project="x64" />
13+
<Configuration Solution="Debug|x64" Project="Debug|x64" />
14+
<Configuration Solution="Publish|x64" Project="Release|x64" />
15+
<Configuration Solution="Release|x64" Project="Release|x64" />
1516
</Project>
1617
<Project Path="H.NotifyIcon/src/libs/H.GeneratedIcons.System.Drawing/H.GeneratedIcons.System.Drawing.csproj">
17-
<BuildType Solution="Publish|*" Project="Release" />
18-
<Platform Project="x64" />
18+
<Configuration Solution="Publish|x64" Project="Release|x64" />
1919
</Project>
2020
<Project Path="H.NotifyIcon/src/libs/H.NotifyIcon.WinUI/H.NotifyIcon.WinUI.csproj">
21-
<BuildType Solution="Publish|*" Project="Release" />
22-
<Platform Project="x64" />
21+
<Configuration Solution="Debug|x64" Project="Debug|x64" />
22+
<Configuration Solution="Publish|x64" Project="Release|x64" />
23+
<Configuration Solution="Release|x64" Project="Release|x64" />
2324
</Project>
2425
<Project Path="H.NotifyIcon/src/libs/H.NotifyIcon/H.NotifyIcon.csproj">
25-
<BuildType Solution="Publish|*" Project="Release" />
26-
<Platform Project="x64" />
26+
<Configuration Solution="Debug|x64" Project="Debug|x64" />
27+
<Configuration Solution="Publish|x64" Project="Release|x64" />
28+
<Configuration Solution="Release|x64" Project="Release|x64" />
2729
</Project>
2830
<Project Path="Hi3Helper.CommunityToolkit/ImageCropper/Hi3Helper.CommunityToolkit.WinUI.Controls.ImageCropper.csproj">
29-
<BuildType Solution="Publish|*" Project="Release" />
30-
<Platform Project="x64" />
31+
<Configuration Solution="Debug|x64" Project="Debug|x64" />
32+
<Configuration Solution="Publish|x64" Project="Release|x64" />
33+
<Configuration Solution="Release|x64" Project="Release|x64" />
3134
</Project>
3235
<Project Path="Hi3Helper.CommunityToolkit/SettingsControls/Hi3Helper.CommunityToolkit.WinUI.Controls.SettingsControls.csproj">
33-
<BuildType Solution="Publish|*" Project="Release" />
34-
<Platform Project="x64" />
36+
<Configuration Solution="Debug|x64" Project="Debug|x64" />
37+
<Configuration Solution="Publish|x64" Project="Release|x64" />
38+
<Configuration Solution="Release|x64" Project="Release|x64" />
3539
</Project>
3640
<Project Path="Hi3Helper.Core/Hi3Helper.Core.csproj">
37-
<Platform Project="x64" />
41+
<Configuration Solution="Debug|x64" Project="Debug|x64" />
42+
<Configuration Solution="Release|x64" Project="Release|x64" />
3843
</Project>
3944
<Project Path="Hi3Helper.EncTool.Test/Hi3Helper.EncTool.Test.csproj">
40-
<BuildType Solution="Publish|*" Project="Release" />
41-
<Platform Project="x64" />
42-
<Build Solution="Publish|*" Project="false" />
43-
<Build Solution="Release|*" Project="false" />
45+
<Configuration Solution="Debug|x64" Project="Debug|x64" />
46+
<Configuration Solution="Publish|x64" Project="Release|x64" />
47+
<Configuration Solution="Release|x64" Project="Release|x64" />
4448
</Project>
4549
<Project Path="Hi3Helper.EncTool/Hi3Helper.EncTool.csproj">
46-
<BuildType Solution="Publish|*" Project="Release" />
47-
<Platform Project="x64" />
50+
<Configuration Solution="Debug|x64" Project="Debug|x64" />
51+
<Configuration Solution="Publish|x64" Project="Release|x64" />
52+
<Configuration Solution="Release|x64" Project="Release|x64" />
4853
</Project>
4954
<Project Path="Hi3Helper.Http/Hi3Helper.Http.csproj">
50-
<BuildType Solution="Publish|*" Project="Release" />
51-
<Platform Project="x64" />
55+
<Configuration Solution="Debug|x64" Project="Debug|x64" />
56+
<Configuration Solution="Publish|x64" Project="Release|x64" />
57+
<Configuration Solution="Release|x64" Project="Release|x64" />
5258
</Project>
5359
<Project Path="Hi3Helper.SharpDiscordRPC/DiscordRPC/DiscordRPC.csproj">
54-
<BuildType Solution="Publish|*" Project="Release" />
55-
<Platform Project="x64" />
60+
<Configuration Solution="Debug|x64" Project="Debug|x64" />
61+
<Configuration Solution="Publish|x64" Project="Release|x64" />
62+
<Configuration Solution="Release|x64" Project="Release|x64" />
5663
</Project>
5764
<Project Path="Hi3Helper.Sophon/Hi3Helper.Sophon.csproj">
58-
<BuildType Solution="Publish|*" Project="Release" />
59-
<Platform Project="x64" />
65+
<Configuration Solution="Debug|x64" Project="Debug|x64" />
66+
<Configuration Solution="Publish|x64" Project="Release|x64" />
67+
<Configuration Solution="Release|x64" Project="Release|x64" />
6068
</Project>
6169
<Project Path="Hi3Helper.TaskScheduler/Hi3Helper.TaskScheduler.csproj">
62-
<BuildType Solution="Publish|*" Project="Release" />
63-
<Platform Project="x64" />
70+
<Configuration Solution="Debug|x64" Project="Debug|x64" />
71+
<Configuration Solution="Publish|x64" Project="Release|x64" />
72+
<Configuration Solution="Release|x64" Project="Release|x64" />
6473
</Project>
6574
<Project Path="Hi3Helper.Win32/Hi3Helper.Win32.csproj">
66-
<BuildType Solution="Publish|*" Project="Release" />
67-
<Platform Project="x64" />
75+
<Configuration Solution="Debug|x64" Project="Debug|x64" />
76+
<Configuration Solution="Publish|x64" Project="Release|x64" />
77+
<Configuration Solution="Release|x64" Project="Release|x64" />
6878
</Project>
6979
<Project Path="Hi3Helper.Win32/WinRT/Hi3Helper.Win32.WinRT.csproj">
70-
<BuildType Solution="Publish|*" Project="Release" />
71-
<Platform Project="x64" />
80+
<Configuration Solution="Debug|x64" Project="Debug|x64" />
81+
<Configuration Solution="Publish|x64" Project="Release|x64" />
82+
<Configuration Solution="Release|x64" Project="Release|x64" />
7283
</Project>
7384
<Project Path="ImageEx/ImageEx/ImageEx.csproj">
74-
<BuildType Solution="Publish|*" Project="Release" />
75-
<Platform Project="x64" />
85+
<Configuration Solution="Debug|x64" Project="Debug|x64" />
86+
<Configuration Solution="Publish|x64" Project="Release|x64" />
87+
<Configuration Solution="Release|x64" Project="Release|x64" />
7688
</Project>
7789
<Project Path="InnoSetupHelper/InnoSetupHelper.csproj">
78-
<BuildType Solution="Publish|*" Project="Release" />
79-
<Platform Project="x64" />
90+
<Configuration Solution="Debug|x64" Project="Debug|x64" />
91+
<Configuration Solution="Publish|x64" Project="Release|x64" />
92+
<Configuration Solution="Release|x64" Project="Release|x64" />
8093
</Project>
8194
<Project Path="SevenZipExtractor/SevenZipExtractor/SevenZipExtractor.csproj">
82-
<BuildType Solution="Publish|*" Project="Release" />
83-
<Platform Project="x64" />
95+
<Configuration Solution="Debug|x64" Project="Debug|x64" />
96+
<Configuration Solution="Publish|x64" Project="Release|x64" />
97+
<Configuration Solution="Release|x64" Project="Release|x64" />
8498
</Project>
85-
</Solution>
99+
</Solution>

CollapseLauncher/Classes/Helper/Background/BackgroundMediaUtility.cs

Lines changed: 30 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
using System.Diagnostics.CodeAnalysis;
1313
using System.IO;
1414
using System.Linq;
15+
using System.Threading;
1516
using System.Threading.Tasks;
16-
using System.Threading.Tasks.Dataflow;
1717
using ImageUI = Microsoft.UI.Xaml.Controls.Image;
1818
// ReSharper disable PartialTypeWithSinglePart
1919
// ReSharper disable AsyncVoidMethod
@@ -49,9 +49,9 @@ internal enum MediaType
4949
[".mp4", ".mov", ".mkv", ".webm", ".avi", ".gif"];
5050

5151
private static FrameworkElement? _parentUI;
52-
private ImageUI? _bgImageBackground;
53-
private ImageUI? _bgImageBackgroundLast;
54-
private MediaPlayerElement? _bgMediaPlayerBackground;
52+
private ImageUI? _bgImageBackground;
53+
private ImageUI? _bgImageBackgroundLast;
54+
private MediaPlayerElement? _bgMediaPlayerBackground;
5555

5656
private Grid? _bgAcrylicMask;
5757
private Grid? _bgOverlayTitleBar;
@@ -70,28 +70,23 @@ internal enum MediaType
7070

7171
private static FileStream? _alternativeFileStream;
7272

73-
private delegate ValueTask AssignDefaultAction<in T>(T element) where T : class;
74-
internal delegate void ThrowExceptionAction(Exception element);
75-
internal static ActionBlock<Task>? SharedActionBlockQueue = new(async action =>
76-
{
77-
try
78-
{
79-
await action;
80-
}
81-
catch (Exception ex)
82-
{
83-
_parentUI?.DispatcherQueue.TryEnqueue(() =>
84-
ErrorSender.SendException(ex));
85-
}
86-
},
87-
new ExecutionDataflowBlockOptions
88-
{
89-
EnsureOrdered = true,
90-
MaxMessagesPerTask = 1,
91-
MaxDegreeOfParallelism = 1,
92-
BoundedCapacity = 1,
93-
TaskScheduler = TaskScheduler.Current
94-
});
73+
private delegate ValueTask AssignDefaultAction<in T>(T element) where T : class;
74+
internal delegate void ThrowExceptionAction(Exception element);
75+
76+
private static bool _isOnQueue;
77+
internal static async void RunQueuedTask(Task task)
78+
{
79+
while (_isOnQueue)
80+
{
81+
await Task.Delay(100);
82+
}
83+
84+
Interlocked.Exchange(ref _isOnQueue, true);
85+
await task;
86+
Interlocked.Exchange(ref _isOnQueue, false);
87+
}
88+
89+
internal static void RunQueuedTask(Action action) => RunQueuedTask(Task.Factory.StartNew(action));
9590

9691
/// <summary>
9792
/// Attach and register the <see cref="Grid" /> of the page to be assigned with background utility.
@@ -319,19 +314,12 @@ private void EnsureCurrentMediaPlayerRegistered()
319314
/// <param name="actionAfterLoaded">Action to do after background is loaded</param>
320315
/// <exception cref="FormatException">Throws if the background file is not supported</exception>
321316
/// <exception cref="NullReferenceException">Throws if some instances aren't yet initialized</exception>
322-
internal async void LoadBackground(string mediaPath,
323-
bool isRequestInit = false,
324-
bool isForceRecreateCache = false,
325-
ThrowExceptionAction? throwAction = null,
326-
Action? actionAfterLoaded = null)
327-
{
328-
while (!await SharedActionBlockQueue?.SendAsync(LoadBackgroundInner(mediaPath, isRequestInit, isForceRecreateCache, throwAction, actionAfterLoaded))!)
329-
{
330-
// Delay the invoke 1/4 second and wait until the action can
331-
// be sent again.
332-
await Task.Delay(250);
333-
}
334-
}
317+
internal void LoadBackground(string mediaPath,
318+
bool isRequestInit = false,
319+
bool isForceRecreateCache = false,
320+
ThrowExceptionAction? throwAction = null,
321+
Action? actionAfterLoaded = null)
322+
=> RunQueuedTask(LoadBackgroundInner(mediaPath, isRequestInit, isForceRecreateCache, throwAction, actionAfterLoaded));
335323

336324
private async Task LoadBackgroundInner(string mediaPath, bool isRequestInit = false,
337325
bool isForceRecreateCache = false, ThrowExceptionAction? throwAction = null,
@@ -340,11 +328,13 @@ private async Task LoadBackgroundInner(string mediaPath, bool
340328
if (mediaPath.Equals(CurrentAppliedMediaPath, StringComparison.OrdinalIgnoreCase))
341329
return;
342330

331+
Interlocked.Exchange(ref CurrentAppliedMediaPath, mediaPath);
332+
343333
try
344334
{
345335
while (!_isCurrentRegistered)
346336
{
347-
await Task.Delay(250, _cancellationToken?.Token ?? default);
337+
await Task.Delay(250, _cancellationToken?.Token ?? CancellationToken.None);
348338
}
349339

350340
EnsureCurrentImageRegistered();
@@ -401,8 +391,6 @@ private async Task LoadBackgroundInner(string mediaPath, bool
401391

402392
CurrentAppliedMediaType = mediaType;
403393
actionAfterLoaded?.Invoke();
404-
405-
CurrentAppliedMediaPath = mediaPath;
406394
}
407395
catch (Exception ex)
408396
{

CollapseLauncher/Classes/Helper/Background/Loaders/MediaPlayerLoader.cs

Lines changed: 6 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
using System.IO;
2222
using System.Threading;
2323
using System.Threading.Tasks;
24-
using System.Threading.Tasks.Dataflow;
2524
using Windows.Foundation;
2625
using Windows.Media.Playback;
2726
using Windows.Storage;
@@ -424,15 +423,9 @@ private async void FrameGrabberEvent(MediaPlayer mediaPlayer, object args)
424423
}
425424
}
426425

427-
public void Dimm()
428-
{
429-
BackgroundMediaUtility.SharedActionBlockQueue?.Post(ToggleImageVisibility(true));
430-
}
426+
public void Dimm() => BackgroundMediaUtility.RunQueuedTask(ToggleImageVisibility(true));
431427

432-
public void Undimm()
433-
{
434-
BackgroundMediaUtility.SharedActionBlockQueue?.Post(ToggleImageVisibility(false));
435-
}
428+
public void Undimm() => BackgroundMediaUtility.RunQueuedTask(ToggleImageVisibility(false));
436429

437430
private async Task ToggleImageVisibility(bool hideImage)
438431
{
@@ -458,10 +451,7 @@ await Task.WhenAll(
458451
);
459452
}
460453

461-
public void Show(bool isForceShow = false)
462-
{
463-
BackgroundMediaUtility.SharedActionBlockQueue?.Post(ShowInner());
464-
}
454+
public void Show(bool isForceShow = false) => BackgroundMediaUtility.RunQueuedTask(ShowInner());
465455

466456
private async Task ShowInner()
467457
{
@@ -480,10 +470,7 @@ await _currentMediaPlayerFrameParentGrid
480470
);
481471
}
482472

483-
public void Hide()
484-
{
485-
BackgroundMediaUtility.SharedActionBlockQueue?.Post(HideInner());
486-
}
473+
public void Hide() => BackgroundMediaUtility.RunQueuedTask(HideInner());
487474

488475
private async Task HideInner()
489476
{
@@ -508,17 +495,7 @@ await _currentMediaPlayerFrameParentGrid
508495
DisposeMediaModules();
509496
}
510497

511-
public async void WindowUnfocused()
512-
{
513-
try
514-
{
515-
await (BackgroundMediaUtility.SharedActionBlockQueue?.SendAsync(WindowUnfocusedInner()) ?? Task.CompletedTask);
516-
}
517-
catch (Exception)
518-
{
519-
// ignored
520-
}
521-
}
498+
public void WindowUnfocused() => BackgroundMediaUtility.RunQueuedTask(WindowUnfocusedInner());
522499

523500
private async Task WindowUnfocusedInner()
524501
{
@@ -527,17 +504,7 @@ private async Task WindowUnfocusedInner()
527504
Pause();
528505
}
529506

530-
public async void WindowFocused()
531-
{
532-
try
533-
{
534-
await (BackgroundMediaUtility.SharedActionBlockQueue?.SendAsync(WindowFocusedInner()) ?? Task.CompletedTask);
535-
}
536-
catch (Exception)
537-
{
538-
// ignored
539-
}
540-
}
507+
public void WindowFocused() => BackgroundMediaUtility.RunQueuedTask(WindowFocusedInner());
541508

542509
private async Task WindowFocusedInner()
543510
{

CollapseLauncher/Classes/Helper/Background/Loaders/StillImageLoader.cs

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -121,15 +121,9 @@ await Task.WhenAll(
121121
);
122122
}
123123

124-
public void Dimm()
125-
{
126-
BackgroundMediaUtility.SharedActionBlockQueue?.Post(ToggleImageVisibility(true));
127-
}
124+
public void Dimm() => BackgroundMediaUtility.RunQueuedTask(ToggleImageVisibility(true));
128125

129-
public void Undimm()
130-
{
131-
BackgroundMediaUtility.SharedActionBlockQueue?.Post(ToggleImageVisibility(false));
132-
}
126+
public void Undimm() => BackgroundMediaUtility.RunQueuedTask(ToggleImageVisibility(false));
133127

134128
private async Task ToggleImageVisibility(bool hideImage, bool completeInvisible = false, bool isForceShow = false)
135129
{
@@ -207,13 +201,13 @@ await Task.WhenAll(
207201
public void Show(bool isForceShow = false)
208202
{
209203
if (ImageBackParentGrid?.Opacity > 0f) return;
210-
BackgroundMediaUtility.SharedActionBlockQueue?.Post(ToggleImageVisibility(false, true, isForceShow));
204+
BackgroundMediaUtility.RunQueuedTask(ToggleImageVisibility(false, true, isForceShow));
211205
}
212206

213207
public void Hide()
214208
{
215209
if (ImageBackParentGrid?.Opacity < 1f) return;
216-
BackgroundMediaUtility.SharedActionBlockQueue?.Post(ToggleImageVisibility(true, true));
210+
BackgroundMediaUtility.RunQueuedTask(ToggleImageVisibility(true, true));
217211
}
218212

219213
public void Mute()

CollapseLauncher/Classes/Helper/Database/DBHandler.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,8 @@ private static void Dispose()
253253
{
254254
LogWriteLine($"[DBHandler::QueryKey] Failed when getting value for key {key}! Retrying...\r\n{ex}",
255255
LogType.Error, true);
256-
break;
256+
257+
await Task.Delay(500);
257258
}
258259
catch (Exception ex) when (!redirectThrow)
259260
{
@@ -320,7 +321,8 @@ public static async Task StoreKeyValue(string key, string value, bool redirectTh
320321
{
321322
LogWriteLine($"[DBHandler::StoreKeyValue] Failed when saving value for key {key}! Retrying...\r\n{ex}",
322323
LogType.Error, true);
323-
break;
324+
325+
await Task.Delay(500);
324326
}
325327
catch (Exception ex) when (!redirectThrow)
326328
{

0 commit comments

Comments
 (0)