66#include " Timemgr.h"
77#include " TimeSpan.h"
88#include < UIThreadScheduler.h>
9+ #include " XamlTelemetry.h"
10+ #include < FrameworkUdk/Containment.h>
11+
12+ // Bug 49537618: [1.5 servicing] DispatcherTimer callbacks are taking much longer on Cadmus
13+ #define WINAPPSDK_CHANGEID_49537618 49537618
914
1015_Check_return_ HRESULT CDispatcherTimer::Create (
1116 _Outptr_ CDependencyObject **ppObject,
@@ -85,6 +90,17 @@ _Check_return_ HRESULT CDispatcherTimer::ComputeStateImpl(
8590 // If we've reached the point where the timer should fire, raise the event and start time over.
8691 if (timeRemainingInMilliseconds <= 0 )
8792 {
93+ if (WinAppSdk::Containment::IsChangeEnabled<WINAPPSDK_CHANGEID_49537618>())
94+ {
95+ TraceLoggingProviderWrite (
96+ XamlTelemetry, " DispatcherTimer_Tick" ,
97+ TraceLoggingUInt64 (reinterpret_cast <uint64_t >(this ), " ObjectPointer" ),
98+ TraceLoggingWideString (m_strName.GetBuffer (), " TimerName" ),
99+ TraceLoggingUInt64 (static_cast <uint64_t >(m_pInterval->m_rTimeSpan * 1000.0 ), " IntervalInMilliseconds" ),
100+ TraceLoggingBoolean (!!m_pEventList, " HasListeners" ),
101+ TraceLoggingLevel (WINEVENT_LEVEL_VERBOSE));
102+ }
103+
88104 FireTickEvent ();
89105
90106 // Snap the time the DispatcherTimer ticked - the next interval is relative to this point.
@@ -167,6 +183,17 @@ _Check_return_ HRESULT CDispatcherTimer::Start()
167183
168184 m_rLastTickTime = pTimeManager->GetEstimatedNextTickTime ();
169185
186+ if (WinAppSdk::Containment::IsChangeEnabled<WINAPPSDK_CHANGEID_49537618>())
187+ {
188+ TraceLoggingProviderWrite (
189+ XamlTelemetry, " DispatcherTimer_Start" ,
190+ TraceLoggingUInt64 (reinterpret_cast <uint64_t >(this ), " ObjectPointer" ),
191+ TraceLoggingWideString (m_strName.GetBuffer (), " TimerName" ),
192+ TraceLoggingUInt64 (static_cast <uint64_t >(m_pInterval->m_rTimeSpan * 1000.0 ), " IntervalInMilliseconds" ),
193+ TraceLoggingUInt64 (static_cast <uint64_t >(m_rLastTickTime * 1000.0 ), " StartTickTimeInMilliseconds" ),
194+ TraceLoggingLevel (WINEVENT_LEVEL_VERBOSE));
195+ }
196+
170197 // Request a tick to update the timeline.
171198 // The browser host and/or frame scheduler can be NULL during shutdown.
172199 IXcpBrowserHost *pBH = core->GetBrowserHost ();
@@ -198,6 +225,16 @@ _Check_return_ HRESULT CDispatcherTimer::Stop()
198225 m_fAddedToManager = FALSE ;
199226 }
200227
228+ if (WinAppSdk::Containment::IsChangeEnabled<WINAPPSDK_CHANGEID_49537618>())
229+ {
230+ TraceLoggingProviderWrite (
231+ XamlTelemetry, " DispatcherTimer_Stop" ,
232+ TraceLoggingUInt64 (reinterpret_cast <uint64_t >(this ), " ObjectPointer" ),
233+ TraceLoggingWideString (m_strName.GetBuffer (), " TimerName" ),
234+ TraceLoggingUInt64 (static_cast <uint64_t >(m_pInterval->m_rTimeSpan * 1000.0 ), " IntervalInMilliseconds" ),
235+ TraceLoggingLevel (WINEVENT_LEVEL_VERBOSE));
236+ }
237+
201238 return S_OK;
202239}
203240
@@ -216,6 +253,17 @@ _Check_return_ HRESULT CDispatcherTimer::WorkComplete()
216253 m_fWorkPending = FALSE ;
217254 m_rLastTickTime = pTimeManager->GetEstimatedNextTickTime ();
218255
256+ if (WinAppSdk::Containment::IsChangeEnabled<WINAPPSDK_CHANGEID_49537618>())
257+ {
258+ TraceLoggingProviderWrite (
259+ XamlTelemetry, " DispatcherTimer_TickComplete" ,
260+ TraceLoggingUInt64 (reinterpret_cast <uint64_t >(this ), " ObjectPointer" ),
261+ TraceLoggingWideString (m_strName.GetBuffer (), " TimerName" ),
262+ TraceLoggingUInt64 (static_cast <uint64_t >(m_pInterval->m_rTimeSpan * 1000.0 ), " IntervalInMilliseconds" ),
263+ TraceLoggingUInt64 (static_cast <uint64_t >(m_rLastTickTime * 1000.0 ), " StartTickTimeInMilliseconds" ),
264+ TraceLoggingLevel (WINEVENT_LEVEL_VERBOSE));
265+ }
266+
219267 // Request a tick to update the timeline.
220268 // The browser host and/or frame scheduler can be NULL during shutdown.
221269 IXcpBrowserHost *pBH = core->GetBrowserHost ();
0 commit comments