Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ namespace Microsoft.Windows.ApplicationModel.WindowsAppRuntime
ListViewSelector_FixFocusedIndex = 61499680,
ModelInitialization_Activities = 61509436,
WindowsML_DiagnosabilityFix = 61592144,

// 1.8.8
AppRuntime_Insights = 61555948,
};

/// Represents a version of the Windows App Runtime.
Expand Down
68 changes: 67 additions & 1 deletion dev/WindowsAppRuntime_Insights/WindowsAppRuntimeInsights.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,22 @@

#include <wil/resource.h>
#include <string>
#include <appmodel.h>
#include <FrameworkUdk/Containment.h>

// Bug 61555948: [1.8.8 servicing] AppRuntime_Insights - Add IsPackagedProcess and IsSelfContained to common insights PartB fields
#define WINAPPSDK_CHANGEID_61555948 61555948, WinAppSDK_1_8_8
namespace Microsoft::WindowsAppRuntime::Insights
{
enum class TraceLoggingInformationFlags : std::uint32_t
{
None = 0,
IsDebuggerPresent = 0x00000001,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

this flag factoring is compact - just want to confirm it's actually useful in reports. i.e., can you filter on specific bit values, or is it just an opaque number? if the latter, I'd stick with unique values.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yeah we can query individual bits, Kusto has bitwise operators like binary_and. And since there's only 3 bits, each combo maps to a unique value (0–7) so we can also filter on the number directly if that's easier. This was Howard's design from #6233 to keep the struct at 4 fields

IsPackagedProcess = 0x00000002,
IsSelfContained = 0x00000004,
};
DEFINE_ENUM_FLAG_OPERATORS(TraceLoggingInformationFlags)

class RuntimeInformation
{
public:
Expand All @@ -32,6 +46,58 @@
return channel;
}

// Inlined from the canonical implementations (see for reference):
// IsPackagedProcess: dev/Common/AppModel.Identity.IsPackagedProcess.h
// IsSelfContained: dev/Common/WindowsAppRuntime.SelfContained.h / .cpp
// Duplicated here to avoid exposing those headers as public API.
static std::uint32_t TraceLoggingInformationFlags()
{
static std::uint32_t flags{ []() -> std::uint32_t {
auto f{ Insights::TraceLoggingInformationFlags::None };

if (wil::details::IsDebuggerPresent())
{
f |= Insights::TraceLoggingInformationFlags::IsDebuggerPresent;
}

if (WinAppSdk::Containment::IsChangeEnabled<WINAPPSDK_CHANGEID_61555948>())
{
{
UINT32 n{};
const auto rc{ ::GetCurrentPackageFullName(&n, nullptr) };
if ((rc != APPMODEL_ERROR_NO_PACKAGE) && (rc != ERROR_INSUFFICIENT_BUFFER))
{
LOG_HR(HRESULT_FROM_WIN32(rc));
}
else if (rc == ERROR_INSUFFICIENT_BUFFER)
{
f |= Insights::TraceLoggingInformationFlags::IsPackagedProcess;
}
}

{
auto module{ ::GetModuleHandleW(L"Microsoft.WindowsAppRuntime.dll") };
if (module)
{
using IsSelfContainedFn = HRESULT(__stdcall*)(BOOL*);
auto fn{ reinterpret_cast<IsSelfContainedFn>(::GetProcAddress(module, "WindowsAppRuntime_IsSelfContained")) };
if (fn)
{
BOOL result{};
if (SUCCEEDED_LOG(fn(&result)) && result)
{
f |= Insights::TraceLoggingInformationFlags::IsSelfContained;
}
}
}
}
}

return static_cast<std::uint32_t>(f);
}() };
return flags;
}

private:
static std::string LoadStringFromResource(uint32_t id)
{
Expand Down Expand Up @@ -60,7 +126,7 @@
TraceLoggingStruct(4, "COMMON_WINDOWSAPPSDK_PARAMS"), \
TraceLoggingString(::Microsoft::WindowsAppRuntime::Insights::RuntimeInformation::WindowsAppRuntimeVersion().c_str(), "Version"), \
TraceLoggingString(::Microsoft::WindowsAppRuntime::Insights::RuntimeInformation::WindowsAppRuntimeChannel().c_str(), "WindowsAppSDKChannel"), \
TraceLoggingBool(wil::details::IsDebuggerPresent(), "IsDebugging"), \
TraceLoggingUInt32(::Microsoft::WindowsAppRuntime::Insights::RuntimeInformation::TraceLoggingInformationFlags(), "Flags"), \
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is definitely not contained. For that reason alone, I'd go with conditional logging of separate bools. Probably makes reporting easier too.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The data values should be contained, when the change is off we just report the debugger bit (0 or 1), same as the old IsDebugging bool. The field name/type is compile-time metadata though, so I'm not sure how to contain that part without duplicating every TraceLoggingWrite call across the ~20 callsites. Open to ideas!

TraceLoggingBool(true, "UTCReplace_AppSessionGuid")

#include <wil/tracelogging.h>
Expand Down
Loading