Skip to content

Commit 091b221

Browse files
committed
Fixed high GPU usage caused by loading animation
1 parent a19e606 commit 091b221

35 files changed

+237
-22
lines changed
20 KB
Binary file not shown.

SyncPlayWPF/SyncPlayWPF/Common/Methods.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,12 +108,12 @@ public static Rect GetAbsolutePlacement(FrameworkElement container, FrameworkEle
108108

109109
public static string ConvertByteSize(int bytecount) {
110110
// Bigger than a giga byte
111-
if (bytecount > 1073741824f) return (bytecount / (1024f * 1024f * 1024f)).ToString() + " GB";
111+
if (bytecount > 1073741824f) return (bytecount / (1024f * 1024f * 1024f)).ToString("0.0") + " GB";
112112

113113
// Bigger than a megabyte
114-
if (bytecount > 1048576f) return (bytecount / (1024f * 1024f)).ToString() + " MB";
114+
if (bytecount > 1048576f) return (bytecount / (1024f * 1024f)).ToString("0.0") + " MB";
115115

116-
return (bytecount / 1024).ToString() + " KB";
116+
return (bytecount / 1024).ToString("0.0") + " KB";
117117
}
118118

119119
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<UserControl x:Class="SyncPlayWPF.Pages.ApplicationPages.Blank"
2+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
5+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
6+
xmlns:local="clr-namespace:SyncPlayWPF.Pages.ApplicationPages"
7+
mc:Ignorable="d"
8+
d:DesignHeight="450" d:DesignWidth="800">
9+
<Grid>
10+
11+
</Grid>
12+
</UserControl>
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
using System.Windows;
7+
using System.Windows.Controls;
8+
using System.Windows.Data;
9+
using System.Windows.Documents;
10+
using System.Windows.Input;
11+
using System.Windows.Media;
12+
using System.Windows.Media.Imaging;
13+
using System.Windows.Navigation;
14+
using System.Windows.Shapes;
15+
16+
namespace SyncPlayWPF.Pages.ApplicationPages {
17+
/// <summary>
18+
/// Interaction logic for Blank.xaml
19+
/// </summary>
20+
public partial class Blank : UserControl {
21+
public Blank() {
22+
InitializeComponent();
23+
}
24+
}
25+
}

SyncPlayWPF/SyncPlayWPF/Pages/NewSessionPage.xaml.cs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ public NewSessionPage() {
2323
InitializeComponent();
2424
}
2525

26+
Pages.ApplicationPages.LoadingScreen LoadingPage = null;
27+
2628
private void JoinRoom_Clicked(object sender, RoutedEventArgs e) {
2729

2830
var serverIp = ServerAddressField.Text.Split(':')[0];
@@ -49,14 +51,18 @@ private void JoinRoom_Clicked(object sender, RoutedEventArgs e) {
4951
Common.Shared.Wrapper.SyncPlayClient.OnDisconnect += SyncPlayClient_OnDisconnect;
5052

5153
Common.Shared.Wrapper.SyncPlayClient.ConnectAsync();
52-
Common.Shared.MasterOverrideTransition.ShowPage(new Pages.ApplicationPages.LoadingScreen());
53-
54+
LoadingPage = new Pages.ApplicationPages.LoadingScreen();
55+
Common.Shared.MasterOverrideTransition.ShowPage(LoadingPage);
56+
5457
}
5558

5659
private void SyncPlayClient_OnDisconnect(SyncPlayClient sender, SyncPlay.SPEventArgs.ServerDisconnectedEventArgs e) {
5760
Console.WriteLine($"Failed to connect. Reasons --> : {e.ReasonForDisconnection}");
5861
Dispatcher.Invoke(() => {
62+
LoadingPage = null;
5963
Common.Shared.MasterOverrideTransition.UnloadCurrentPage();
64+
Common.Shared.MasterOverrideTransition.ShowPage(new ApplicationPages.Blank());
65+
GC.Collect();
6066
Common.Shared.Wrapper.SyncPlayClient.OnConnect -= SyncPlayClient_OnConnect;
6167
Common.Shared.Wrapper.SyncPlayClient.OnDisconnect -= SyncPlayClient_OnDisconnect;
6268
});
@@ -66,9 +72,12 @@ private void SyncPlayClient_OnDisconnect(SyncPlayClient sender, SyncPlay.SPEvent
6672
}
6773

6874
private void SyncPlayClient_OnConnect(SyncPlayClient sender, SyncPlay.SPEventArgs.ServerConnectedEventArgs e) {
69-
Console.WriteLine("Connection established");
75+
7076
Dispatcher.Invoke(() => {
77+
Console.WriteLine("Connection established at connector");
78+
LoadingPage = null;
7179
Common.Shared.MasterOverrideTransition.UnloadCurrentPage();
80+
Common.Shared.MasterOverrideTransition.ShowPage(new ApplicationPages.Blank());
7281
Common.Shared.WindowPageTransition.ShowPage(new Pages.SessionLandingPage());
7382
});
7483
}

SyncPlayWPF/SyncPlayWPF/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,5 +51,5 @@
5151
// You can specify all the values or you can default the Build and Revision Numbers
5252
// by using the '*' as shown below:
5353
// [assembly: AssemblyVersion("1.0.*")]
54-
[assembly: AssemblyVersion("2021.249.22.0")]
55-
[assembly: AssemblyFileVersion("2021.249.22.0")]
54+
[assembly: AssemblyVersion("2021.249.46.0")]
55+
[assembly: AssemblyFileVersion("2021.249.46.0")]

SyncPlayWPF/SyncPlayWPF/SyncPlayWPF.csproj

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,9 @@
109109
<Compile Include="CustomControls\StatusImage.cs" />
110110
<Compile Include="CustomControls\ToastNotification.cs" />
111111
<Compile Include="CustomControls\UserSessionView.cs" />
112+
<Compile Include="Pages\ApplicationPages\Blank.xaml.cs">
113+
<DependentUpon>Blank.xaml</DependentUpon>
114+
</Compile>
112115
<Compile Include="Pages\ApplicationPages\ExceptionView.xaml.cs">
113116
<DependentUpon>ExceptionView.xaml</DependentUpon>
114117
</Compile>
@@ -166,6 +169,10 @@
166169
<DependentUpon>MainWindow.xaml</DependentUpon>
167170
<SubType>Code</SubType>
168171
</Compile>
172+
<Page Include="Pages\ApplicationPages\Blank.xaml">
173+
<SubType>Designer</SubType>
174+
<Generator>MSBuild:Compile</Generator>
175+
</Page>
169176
<Page Include="Pages\ApplicationPages\ExceptionView.xaml">
170177
<SubType>Designer</SubType>
171178
<Generator>MSBuild:Compile</Generator>

SyncPlayWPF/SyncPlayWPF/Themes/Generic.xaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -254,11 +254,11 @@
254254
Stretch="Uniform"
255255
RenderOptions.BitmapScalingMode="HighQuality"/>
256256
</Border.OpacityMask>
257-
<Border.Effect>
257+
<!--<Border.Effect>
258258
<DropShadowEffect
259259
BlurRadius="10"
260260
ShadowDepth="1"/>
261-
</Border.Effect>
261+
</Border.Effect>-->
262262
<Border.Style>
263263
<Style TargetType="{x:Type Border}">
264264
<Setter Property="Background" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=ImageBackgroundBrush}"/>
@@ -304,9 +304,9 @@
304304
RenderOptions.BitmapScalingMode="HighQuality"/>
305305
</Rectangle.OpacityMask>
306306

307-
<Rectangle.Effect>
307+
<!--<Rectangle.Effect>
308308
<DropShadowEffect BlurRadius="10" ShadowDepth="0" Opacity="0.5"/>
309-
</Rectangle.Effect>
309+
</Rectangle.Effect>-->
310310

311311
<Rectangle.Style>
312312
<Style TargetType="{x:Type Rectangle}">
1 KB
Binary file not shown.
8 KB
Binary file not shown.

0 commit comments

Comments
 (0)