Description
Describe the bug
Instrumentor::BeginSession() does not check to see if there is already an instrumentation session active.
The existing session (if it exists) is not ended properly which a) means the results json file wont load nicely into chrome://tracing because it is not complete, and b) leaks an InstrumentationSession instance.
To Reproduce
The following example is somewhat contrived (because the instrumentation code is for Hazel devs only, so wouldn't normally be found in "client" code. Nevertheless, it does illustrate the problem:
If/When Hazel becomes multi-threaded, there becomes more ways to reproduce the problem.
Add the following to SandboxApp.cpp, which you might think could be used to profile the creation of SandBox in a separate instrumentation session.
Hazel::Application* Hazel::CreateApplication() { Hazel::Instrumentor::Get().BeginSession("innocent mistake", "mistake.json"); // <- -Add this line Hazel::Application* app = new Sandbox(); Hazel::Instrumentor::Get().EndSession(); // <-- Add this line bool result = handle.get(); return app; }
Expected behavior
All profile result .json files should be valid json, and load cleanly into chrome://tracing
InstrumentationSession objects should not be leaked.
Operating system: (please complete the following information)
- OS: N/A problem is not OS specific
Activity