Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion build/Stride.slnx
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,6 @@
<Project Path="../sources/editor/Stride.Editor.CrashReport/Stride.Editor.CrashReport.csproj" />
<Project Path="../sources/editor/Stride.Editor/Stride.Editor.csproj" />
<Project Path="../sources/editor/Stride.GameStudio/Stride.GameStudio.csproj" DefaultStartup="true" />
<Project Path="../sources/editor/Stride.PrivacyPolicy/Stride.PrivacyPolicy.shproj" />
<Project Path="../sources/engine/Stride.Debugger/Stride.Debugger.csproj" />
</Folder>
<Folder Name="/61-Editor.Tests/">
Expand Down
1 change: 0 additions & 1 deletion sources/Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,6 @@
<PackageVersion Include="Microsoft.Win32.Registry" Version="5.0.0" />
<PackageVersion Include="Microsoft-WindowsAPICodePack-Shell" Version="1.1.5" />
<PackageVersion Include="Stride.GraphX.WPF.Controls" Version="2.4.0" />
<PackageVersion Include="Stride.Metrics" Version="1.0.3" />
<PackageVersion Include="RoslynPad.Editor.Windows" Version="5.0.0" />
<PackageVersion Include="RoslynPad.Roslyn" Version="5.0.0" />
<PackageVersion Include="RoslynPad.Roslyn.Windows" Version="5.0.0" />
Expand Down
33 changes: 9 additions & 24 deletions sources/core/Stride.Core.Design/Windows/AppHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Management;
using System.Text;
using Stride.Core.Extensions;
using System.Runtime.InteropServices;

namespace Stride.Core.Windows;

Expand All @@ -24,35 +25,14 @@ public static string BuildErrorMessage(Exception exception, string? header = nul
}
body.AppendLine($"Current Directory: {Environment.CurrentDirectory}");
body.AppendLine($"Command Line Args: {string.Join(" ", GetCommandLineArgs())}");
body.AppendLine($"OS Version: {Environment.OSVersion} ({(Environment.Is64BitOperatingSystem ? "x64" : "x86")})");
body.AppendLine($"OS Version: {RuntimeInformation.OSDescription} ({(Environment.Is64BitOperatingSystem ? "x64" : "x86")})");
body.AppendLine($"Processor Count: {Environment.ProcessorCount}");
body.AppendLine("Video configuration:");
WriteVideoConfig(body);
body.AppendLine($"Exception: {exception.FormatFull()}");
return body.ToString();
}

internal static void WriteMemoryInfo(StringBuilder writer)
{
// Not used yet, but we might want to include some of these info
try
{
var searcher = new ManagementObjectSearcher("SELECT * FROM CIM_OperatingSystem");

foreach (var managementObject in searcher.Get().OfType<ManagementObject>())
{
foreach (var property in managementObject.Properties)
{
writer.AppendLine($"{property.Name}: {property.Value}");
}
}
}
catch (Exception)
{
writer.AppendLine("An error occurred while trying to retrieve memory information.");
}
}

public static void WriteVideoConfig(StringBuilder writer)
{
try
Expand Down Expand Up @@ -82,7 +62,14 @@ public static Dictionary<string, string> GetVideoConfig()
private static Dictionary<string, string> GetVideoConfigWindows()
{
var result = new Dictionary<string, string>();
if (OperatingSystem.IsWindows())
GetVideoConfigWindows(result);

return result;
}

private static void GetVideoConfigWindows(Dictionary<string, string> result)
{
try
{
var searcher = new ManagementObjectSearcher("SELECT * FROM Win32_VideoController");
Expand All @@ -102,7 +89,5 @@ private static Dictionary<string, string> GetVideoConfigWindows()
{
// ignored
}

return result;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,6 @@ static EditorSettings()
DisplayName = $"{Interface}/{Tr._p("Settings", "Ask before saving new scripts")}",
Description = Tr._p("Settings", "Ask before saving new scripts"),
};
EnableMetrics = new SettingsKey<bool>("Interface/ToggleMetrics", SettingsContainer, true)
{
DisplayName = $"{Interface}/{Tr._p("Settings", "Usage Analytics")}",
Description = Tr._p("Settings", "Anonymous usage analytics to help the Stride community improve the software. Statistics on installation, version-specific usage, and platform popularity. The data is open-source at https://metrics.stride3d.net")
};
Language = new SettingsKey<SupportedLanguage>("Interface/Language", SettingsContainer, SupportedLanguage.MachineDefault)
{
DisplayName = $"{Interface}/{Tr._p("Settings", "Language")}",
Expand Down Expand Up @@ -126,8 +121,6 @@ static EditorSettings()

public static SettingsKey<bool> ReloadLastSession { get; }

public static SettingsKey<bool> EnableMetrics { get; }

/// <summary>Value meaning "follow the platform default" for <see cref="GraphicsApi"/>.</summary>
public const string GraphicsApiDefault = "Default";

Expand All @@ -144,7 +137,6 @@ public static void Initialize()
// Settings that requires a restart must register here:
UseEffectCompilerServer.ChangesValidated += (s, e) => NeedRestart = true;
Language.ChangesValidated += (s, e) => NeedRestart = true;
EnableMetrics.ChangesValidated += (s, e) => NeedRestart = true;
GraphicsApi.ChangesValidated += (s, e) => NeedRestart = true;

Presentation.Themes.ThemesSettings.ThemeName.ChangesValidated += (s, e) => NeedRestart = true;
Expand Down
11 changes: 0 additions & 11 deletions sources/editor/Stride.GameStudio.AutoTesting/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,6 @@ public static int Main(string[] osArgs)
// to WARP. Must be set before any Stride code runs.
Environment.SetEnvironmentVariable("STRIDE_GRAPHICS_SOFTWARE_RENDERING", "1");

// Pre-accept the Stride 4.0 privacy policy: PrivacyPolicyHelper would otherwise pop a
// modal at startup with no one to click Accept on CI.
try
{
using var subkey = Microsoft.Win32.Registry.CurrentUser
.OpenSubKey(@"SOFTWARE\Stride\Agreements\", writable: true)
?? Microsoft.Win32.Registry.CurrentUser.CreateSubKey(@"SOFTWARE\Stride\Agreements\");
subkey?.SetValue("Stride-4.0", "True");
}
catch { /* best-effort — failure shows up as the privacy-policy hang */ }

// Clear the "last startup-session load crashed" sticky flag — a previous AutoTesting run
// that timed out / was killed leaves it on, which makes OpenInitialSession pop a "try
// again?" MessageBox with no one to click. Always reset before launching GS.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,6 @@ public static void SendReport(string exceptionMessage, int crashLocation, string

var reporter = new CrashReportWindow(crashReport, "Stride GameStudio");
var result = reporter.ShowDialog();
StrideGameStudio.MetricsClient?.CrashedSession(result is true);
}

private static void ExpandAction(TransactionViewModel actionItem, StringBuilder sb, int increment)
Expand Down
3 changes: 0 additions & 3 deletions sources/editor/Stride.GameStudio/Helpers/StrideGameStudio.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
using System.Runtime.InteropServices;
using Stride.Core.Annotations;
using Stride.Graphics;
using Stride.Metrics;

namespace Stride.GameStudio.Helpers
{
Expand Down Expand Up @@ -44,7 +43,5 @@ public static class StrideGameStudio

[NotNull]
public static string ReportIssueUrl => "https://github.com/stride3d/stride/issues/";

public static MetricsClient MetricsClient;
}
}
191 changes: 87 additions & 104 deletions sources/editor/Stride.GameStudio/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@
using Stride.GameStudio.View;
using Stride.GameStudio.ViewModels;
using Stride.Graphics;
using Stride.Metrics;
using Stride.PrivacyPolicy;
using EditorSettings = Stride.Core.Assets.Editor.Settings.EditorSettings;
using MessageBox = System.Windows.MessageBox;
using MessageBoxButton = System.Windows.MessageBoxButton;
Expand Down Expand Up @@ -114,9 +112,6 @@ public static void Run(IList<string> args, Action<Application, Dispatcher>? appH
Environment.Exit(1);
}

PrivacyPolicyHelper.RestartApplication = RestartApplication;
PrivacyPolicyHelper.EnsurePrivacyPolicyStride40();

// We use MRU of the current version only when we're trying to reload last session.
var mru = new MostRecentlyUsedFileCollection(InternalSettings.LoadProfileCopy, InternalSettings.MostRecentlyUsedSessions, InternalSettings.WriteFile);
mru.LoadFromSettings();
Expand All @@ -129,119 +124,107 @@ public static void Run(IList<string> args, Action<Application, Dispatcher>? appH
}
Thread.CurrentThread.Name = "Main thread";

// Install Metrics for the editor
using (StrideGameStudio.MetricsClient = EditorSettings.EnableMetrics.GetValue() ? new MetricsClient(CommonApps.StrideEditorAppId) : null)
try
{
try
{
var startupSessionPath = StrideEditorSettings.StartupSession.GetValue();
var lastSessionPath = EditorSettings.ReloadLastSession.GetValue() ? mru.MostRecentlyUsedFiles.FirstOrDefault() : null;
var initialSessionPath = !UPath.IsNullOrEmpty(startupSessionPath) ? startupSessionPath : lastSessionPath?.FilePath;
var startupSessionPath = StrideEditorSettings.StartupSession.GetValue();
var lastSessionPath = EditorSettings.ReloadLastSession.GetValue() ? mru.MostRecentlyUsedFiles.FirstOrDefault() : null;
var initialSessionPath = !UPath.IsNullOrEmpty(startupSessionPath) ? startupSessionPath : lastSessionPath?.FilePath;

// Handle arguments
for (var i = 0; i < args.Count; i++)
// Handle arguments
for (var i = 0; i < args.Count; i++)
{
if (args[i] == "/LauncherWindowHandle")
{
windowHandle = new IntPtr(long.Parse(args[++i]));
}
else if (args[i] == "/NewProject")
{
initialSessionPath = null;
}
else if (args[i] == "/DebugEditorGraphics")
{
StrideConfig.GraphicsDebugMode = true;
}
else if (args[i] == "--graphics-api")
{
// Consumed at startup by GraphicsApiSelector; skip the following value here.
i++;
}
else if (args[i] == "/DisableThumbnails")
{
enableThumbnailServices = false;
}
else if (args[i] == "/DisablePreview")
{
if (args[i] == "/LauncherWindowHandle")
{
windowHandle = new IntPtr(long.Parse(args[++i]));
}
else if (args[i] == "/NewProject")
{
initialSessionPath = null;
}
else if (args[i] == "/DebugEditorGraphics")
{
StrideConfig.GraphicsDebugMode = true;
}
else if (args[i] == "--graphics-api")
{
// Consumed at startup by GraphicsApiSelector; skip the following value here.
i++;
}
else if (args[i] == "/DisableThumbnails")
{
enableThumbnailServices = false;
}
else if (args[i] == "/DisablePreview")
{
GameStudioPreviewService.DisablePreview = true;
}
GameStudioPreviewService.DisablePreview = true;
}
#if STRIDE_GRAPHICS_API_DIRECT3D12
else if (args[i] == "/PixGpuCapturer")
{
WinPixNative.LoadPixGpuCapturer();
}
else if (args[i] == "/PixGpuCapturer")
{
WinPixNative.LoadPixGpuCapturer();
}
#endif
else if (args[i] == "/RenderDoc")
{
// TODO: RenderDoc is not working here (when not in debug)
GameStudioPreviewService.DisablePreview = true;
renderDocManager = new RenderDocManager();
renderDocManager.Initialize();
}
else if (args[i] == "/RecordEffects")
{
GameStudioBuilderService.GlobalEffectLogPath = args[++i];
}
else
{
initialSessionPath = args[i];
}
else if (args[i] == "/RenderDoc")
{
// TODO: RenderDoc is not working here (when not in debug)
GameStudioPreviewService.DisablePreview = true;
renderDocManager = new RenderDocManager();
renderDocManager.Initialize();
}
else if (args[i] == "/RecordEffects")
{
GameStudioBuilderService.GlobalEffectLogPath = args[++i];
}
else
{
initialSessionPath = args[i];
}
RuntimeHelpers.RunModuleConstructor(typeof(Asset).Module.ModuleHandle);
}
RuntimeHelpers.RunModuleConstructor(typeof(Asset).Module.ModuleHandle);

//listen to logger for crash report
GlobalLogger.GlobalMessageLogged += GlobalLoggerOnGlobalMessageLogged;
// Route GlobalLogger output to VS Debug pane (no-op in Release).
// Warning+ only — Info/Verbose volume slows the debugger noticeably during
// asset compile / NuGet restore.
GlobalLogger.GlobalMessageLogged += new DebugLogListener { MinimumLevel = LogMessageType.Warning };
//listen to logger for crash report
GlobalLogger.GlobalMessageLogged += GlobalLoggerOnGlobalMessageLogged;
// Route GlobalLogger output to VS Debug pane (no-op in Release).
// Warning+ only — Info/Verbose volume slows the debugger noticeably during
// asset compile / NuGet restore.
GlobalLogger.GlobalMessageLogged += new DebugLogListener { MinimumLevel = LogMessageType.Warning };

mainDispatcher = Dispatcher.CurrentDispatcher;
mainDispatcher.InvokeAsync(() =>
mainDispatcher = Dispatcher.CurrentDispatcher;
mainDispatcher.InvokeAsync(() =>
{
// Surface startup failures that escape Startup before its first await, instead of
// leaving the dispatcher pumping with no window.
try
{
// Surface startup failures that escape Startup before its first await, instead of
// leaving the dispatcher pumping with no window.
try
{
Startup(initialSessionPath);
}
catch (Exception ex)
{
HandleException(ex, 0);
}
});

using (new WindowManager(mainDispatcher))
Startup(initialSessionPath);
}
catch (Exception ex)
{
app = new App { ShutdownMode = ShutdownMode.OnExplicitShutdown };
app.DispatcherUnhandledException += (sender, eventArgs) =>
{
eventArgs.Handled = true;
HandleException(eventArgs.Exception, 0);
};
app.Activated += (sender, eventArgs) =>
{
StrideGameStudio.MetricsClient?.SetActiveState(true);
};
app.Deactivated += (sender, eventArgs) =>
{
StrideGameStudio.MetricsClient?.SetActiveState(false);
};

app.InitializeComponent();
appHosted?.Invoke(app, mainDispatcher);
DiagLog("calling app.Run");
app.Run();
DiagLog("app.Run returned");
HandleException(ex, 0);
}
});

renderDocManager?.RemoveHooks();
}
catch (Exception e)
using (new WindowManager(mainDispatcher))
{
HandleException(e, 0);
app = new App { ShutdownMode = ShutdownMode.OnExplicitShutdown };
app.DispatcherUnhandledException += (sender, eventArgs) =>
{
eventArgs.Handled = true;
HandleException(eventArgs.Exception, 0);
};

app.InitializeComponent();
appHosted?.Invoke(app, mainDispatcher);
DiagLog("calling app.Run");
app.Run();
DiagLog("app.Run returned");
}

renderDocManager?.RemoveHooks();
}
catch (Exception e)
{
HandleException(e, 0);
}
}

Expand Down
Loading
Loading