Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Building playbackengine #622

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft

Conversation

bitsandfoxes
Copy link
Contributor

@bitsandfoxes bitsandfoxes commented Mar 9, 2022

To note:

  • the whole functionality is behind an opt-in feature flag AddSentryToWindowsPlayer on the editor options for now
  • renaming SentryCliOptions to EditorOptions is a breaking change
  • the actual project manipulation for the player is still missing

#skip-changelog

@github-actions
Copy link
Contributor

github-actions bot commented Mar 9, 2022

Messages
📖 Do not forget to update Sentry-docs with your feature once the pull request gets approved.

Generated by 🚫 dangerJS against 7f3fb97

Copy link
Member

@bruno-garcia bruno-garcia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm very uneasy about the approach of finding msbuild and recompiling that project. I know I got convinced on our last call but I believe we need the trade offs (and risks) written down somewhere and involve other folks before we go ahead. I worry about side effects beyond building this one project (e.g: What if I have 2 unity projects open?)


namespace Sentry.Unity.Editor
{
internal static class EditorFileIO
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this only operations that can run on the editor? The type lives in the Sentry.Unity.Editor so that's covered so what about dropping Editor from the name?

It seems we have some wrappers over Unity's FileUtil with some logging and dealing with directories being created. Do we need to use that so Unity can track things or we could just use File and Directory classes from the BCL?

What if we just call this SentryFileUtil or simply FileUtil:

Suggested change
internal static class EditorFileIO
internal static class FileUtil

src/Sentry.Unity.Editor/EditorFileIO.cs Outdated Show resolved Hide resolved
src/Sentry.Unity.Editor/Native/SentryWindowsPlayer.cs Outdated Show resolved Hide resolved
src/Sentry.Unity.Editor/Native/SentryWindowsPlayer.cs Outdated Show resolved Hide resolved
src/Sentry.Unity.Editor/Native/SentryWindowsPlayer.cs Outdated Show resolved Hide resolved
src/Sentry.Unity.Editor/Native/SentryWindowsPlayer.cs Outdated Show resolved Hide resolved
src/Sentry.Unity.Editor/Native/SentryWindowsPlayer.cs Outdated Show resolved Hide resolved
src/Sentry.Unity.Editor/Native/SentryWindowsPlayer.cs Outdated Show resolved Hide resolved
src/Sentry.Unity.Editor/Native/SentryWindowsPlayer.cs Outdated Show resolved Hide resolved
src/Sentry.Unity.Editor/Native/SentryWindowsPlayer.cs Outdated Show resolved Hide resolved
Copy link
Member

@bruno-garcia bruno-garcia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀

{
if (!File.Exists(editorOptions.MSBuildPath))
{
logger.LogDebug("Failed to find 'MSBuild' at '{0}'. Trying to locate.", editorOptions.MSBuildPath);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
logger.LogDebug("Failed to find 'MSBuild' at '{0}'. Trying to locate.", editorOptions.MSBuildPath);
logger.LogDebug("'MSBuild' not known. '{0}'. Trying to locate.", editorOptions.MSBuildPath);

{
if (!File.Exists(editorOptions.VSWherePath))
{
logger?.LogDebug("Failed to find 'VSWhere' at '{0}'. Trying to locate.", editorOptions.VSWherePath);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
logger?.LogDebug("Failed to find 'VSWhere' at '{0}'. Trying to locate.", editorOptions.VSWherePath);
logger?.LogDebug("Path to 'VSWhere' not known. Have '{0}'. Trying to locate.", editorOptions.VSWherePath);

StartInfo = new ProcessStartInfo
{
FileName = editorOptions.VSWherePath,
Arguments = "-latest -requires Microsoft.Component.MSBuild -find MSBuild\\**\\Bin\\MSBuild.exe",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we check if the file we found is signed?
Does Unity also run this same command? Finding a file like this and executing it?


logger?.LogDebug("Using 'VSWhere' at '{0}' to locate MSBuild.", editorOptions.VSWherePath);

var vsWhereOutput = "";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
var vsWhereOutput = "";
var vsWhereOutput = new StringBuilder();


logger?.LogDebug("Using 'VSWhere' at '{0}' to locate MSBuild.", editorOptions.VSWherePath);

var vsWhereOutput = "";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
var vsWhereOutput = "";
// The program only returns one line
var vsWhereOutput = "";


if (!File.Exists(vsWhereOutput))
{
throw new FileNotFoundException($"Failed to locate 'MSBuild'.");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where do we handle this? Do we downgrade to initalizing the SDK at runtime?

var packageListRequest = Client.List(true);
while (!packageListRequest.IsCompleted)
{
// TODO: timeout - can't use Task.Run because it has to be on the main thread
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Basic timeout could be something this:

Suggested change
// TODO: timeout - can't use Task.Run because it has to be on the main thread
Thread.Sleep(100);
if (counter++ * 10 > timeoutMillisecond)

process.WaitForExit();

var logFile = Path.Combine(_projectPath, "build.log");
File.WriteAllText(logFile, output.ToString());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of allocating the whole string and writing it with WriteAllText it's better to use a different API and stream data through.

Instead of a string builder, get an OutputStream and just write the data straight into it.
I think the Process class already has streams you can hook into and write into a FileStream.

EditorFileIO.CopyDirectory(projectSource, projectTarget, logger);

// TODO: Does the .props file have to look like that?
// The 'UnityCommon.props' is missing from the provided source code
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if this is fixed on future versions? Maybe check if it's already there before doing this?

EditorGUI.DrawRect(EditorGUILayout.GetControlRect(false, 1), Color.gray);
EditorGUILayout.Space();

EditorGUILayout.Toggle("Add Sentry to Windows Player", cliOptions.AddSentryToWindowsPlayer);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what about using: Initialize and "native crash" in the name somehow?

@getsantry
Copy link

getsantry bot commented Oct 18, 2023

This issue has gone three weeks without activity. In another week, I will close it.

But! If you comment or otherwise update it, I will reset the clock, and if you remove the label Waiting for: Community, I will leave it alone ... forever!


"A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀

@getsantry getsantry bot added the Stale label Oct 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants