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: add analyticsKernelService with renderer-protocol #3605

Closed
wants to merge 36 commits into from

Conversation

kuruk-mm
Copy link
Member

@kuruk-mm kuruk-mm commented Nov 28, 2022

What does this PR change?

Use renderer-protocol instead of JSON-based communication

Test

Our Code Review Standards

https://github.com/decentraland/unity-renderer/blob/master/docs/code-review-standards.md

@github-actions
Copy link
Contributor

github-actions bot commented Nov 28, 2022

@kuruk-mm kuruk-mm changed the base branch from dev to feat/ensure-rpc November 29, 2022 13:14
@kuruk-mm kuruk-mm requested a review from AjimenezDCL November 30, 2022 15:47
@kuruk-mm kuruk-mm marked this pull request as ready for review December 1, 2022 01:46
@github-actions github-actions bot requested a review from kwssbocian December 1, 2022 01:46
@kuruk-mm kuruk-mm removed the request for review from kwssbocian December 1, 2022 01:46
@kuruk-mm kuruk-mm added the No QA Needed Issues which do not require QA testing label Dec 1, 2022
// TODO: remove useBinaryTransform after ECS7 is fully in prod
UseBinaryTransform = true,
});

// We trigger the Decentraland logic once everything is initialized.
WebInterface.StartDecentraland();
Copy link
Member Author

Choose a reason for hiding this comment

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

This function, starts the engine calling the web directly. And from the Kernel side, starts everything, including the RPC.

So I had to move the rpc call after this StartDecentraland()

Signed-off-by: Mateo Miccino <mateomiccino@gmail.com>
@kuruk-mm kuruk-mm marked this pull request as ready for review December 2, 2022 18:12
Comment on lines +38 to +41
// this event should be the last one to be executed after initialization
// it is used by the kernel to signal "EngineReady" or something like that
// to prevent race conditions like "SceneController is not an object",
// aka sending events before unity is ready
Copy link
Contributor

Choose a reason for hiding this comment

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

We should document all this setup process somewhere, what type of signasl are required between kernel/renderer to start decentraland.

Also bear in mind we are aiming to register KernelServices as IService in the ServiceLocator, this initialization will be moved (probably to a subsystem in Main or similar). In the meantime we can have it here.

Copy link
Collaborator

Choose a reason for hiding this comment

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

i think this method lacks of cohesion. Why is it called StartRpc but does an analytics system reports saying that should be the last thing to be called? Perhaps a rename: ReportSystemInfoToAnalytics

@kuruk-mm kuruk-mm requested a review from lorux0 December 14, 2022 20:47
internal void SendToSegment(string eventName, Dictionary<string, string> data) { WebInterface.ReportAnalyticsEvent(eventName, data.Select(x => new WebInterface.AnalyticsPayload.Property(x.Key, x.Value)).ToArray()); }
internal void SendToSegment(string eventName, Dictionary<string, string> data)
{
ClientAnalyticsKernelService analytics = DCL.Environment.i.serviceLocator.Get<IRPC>().Analytics();
Copy link
Collaborator

Choose a reason for hiding this comment

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

could you inject the IRPC dependency?

};

var result = JsonConvert.SerializeObject(performanceReportPayload);
WebInterface.SendPerformanceReport(result);
ClientAnalyticsKernelService analytics = Environment.i.serviceLocator.Get<IRPC>().Analytics();
Copy link
Collaborator

Choose a reason for hiding this comment

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

could you inject IRPC dependency?

Comment on lines +38 to +41
// this event should be the last one to be executed after initialization
// it is used by the kernel to signal "EngineReady" or something like that
// to prevent race conditions like "SceneController is not an object",
// aka sending events before unity is ready
Copy link
Collaborator

Choose a reason for hiding this comment

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

i think this method lacks of cohesion. Why is it called StartRpc but does an analytics system reports saying that should be the last thing to be called? Perhaps a rename: ReportSystemInfoToAnalytics

@@ -210,7 +212,9 @@ public void SetTutorialDisabled()
commonDataStore.isTutorialRunning.Set(false);
tutorialView.tutorialMusicHandler.StopTutorialMusic();
ShowTeacher3DModel(false);
WebInterface.SetDelightedSurveyEnabled(true);

ClientAnalyticsKernelService analytics = DCL.Environment.i.serviceLocator.Get<IRPC>().Analytics();
Copy link
Collaborator

Choose a reason for hiding this comment

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

can you inject IRPC dependency?

};

WebInterface.ReportAnalyticsEvent("tutorial step started", properties);
ClientAnalyticsKernelService analytics = DCL.Environment.i.serviceLocator.Get<IRPC>().Analytics();
Copy link
Collaborator

Choose a reason for hiding this comment

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

avoid singletons coupling if possible

Comment on lines +143 to +167
Samples = encodedSamples,
FpsIsCapped = usingFPSCap,
HiccupsInThousandFrames = hiccupsInThousandFrames,
HiccupsTime = hiccupsTime,
TotalTime = totalTime,
GltfInProgress = gltfloading,
GltfFailed = gltffailed,
GltfCancelled = gltfcancelled,
GltfLoaded = gltfloaded,
AbInProgress = abloading,
AbFailed = abfailed,
AbCancelled = abcancelled,
AbLoaded = abloaded,
GltfTexturesLoaded = gltfTextures,
AbTexturesLoaded = abTextures,
PromiseTexturesLoaded = promiseTextures,
EnqueuedMessages = queuedMessages,
ProcessedMessages = processedMessages,
PlayerCount = playerCount,
LoadRadius = (int) loadRadius,
SceneScores = { scenesMemoryScore },
DrawCalls = (int) drawCalls!,
MemoryReserved = (long) totalMemoryReserved!,
MemoryUsage = (long) totalMemoryUsage,
TotalGcAlloc = (long) totalGCAlloc,
Copy link
Member

Choose a reason for hiding this comment

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

Wouldn't this case change involve a change in the behavior? Can we have the linter ignore these?

Copy link
Member Author

Choose a reason for hiding this comment

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

In theory, it should not change anything. It's sending with the new RPC instead of JSON.

@eordano eordano requested a review from a team as a code owner February 6, 2023 16:14
@kuruk-mm kuruk-mm requested a review from lorux0 March 6, 2023 20:46
@@ -1,5 +1,9 @@
fileFormatVersion: 2
<<<<<<< HEAD:unity-renderer/Assets/Scripts/MainScripts/DCL/WorldRuntime/KernelCommunication/RPC/GeneratedCode/Decentraland/renderer/kernel_services/AnalyticsService.gen.cs.meta
Copy link
Collaborator

Choose a reason for hiding this comment

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

wrong conflict solving

@aixaCode
Copy link
Collaborator

aixaCode commented Apr 6, 2023

@kuruk-mm Is this still PR valid? What is the status with that?

@kuruk-mm kuruk-mm closed this May 17, 2023
@kuruk-mm
Copy link
Member Author

Closing. Not more valid

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
No QA Needed Issues which do not require QA testing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants