Skip to content

Commit

Permalink
Syncing content from committish e6d40aca3643d400bddd622870a3422ccbe5f27c
Browse files Browse the repository at this point in the history
  • Loading branch information
reunion-maestro-bot committed Apr 11, 2024
1 parent 3d10001 commit b91b3ce
Show file tree
Hide file tree
Showing 11 changed files with 217 additions and 71 deletions.
32 changes: 11 additions & 21 deletions controls/dev/ItemsView/ItemsView.cpp
Expand Up @@ -2083,42 +2083,32 @@ void ItemsView::SetItemsViewItemContainerRevokers(

itemContainer.SetValue(s_ItemsViewItemContainerRevokersProperty, itemContainerRevokers.as<winrt::IInspectable>());

m_itemContainersWithRevokers.insert(tracker_ref<winrt::ItemContainer>{ this, itemContainer });
m_itemContainersWithRevokers.insert(itemContainer);
}

void ItemsView::ClearItemsViewItemContainerRevokers(
const winrt::ItemContainer& itemContainer)
{
const auto& itemContainerRef = tracker_ref<winrt::ItemContainer>{ this, itemContainer };
const auto& itemContainerSafe = itemContainerRef.safe_get();
if (itemContainerSafe)
{
RevokeItemsViewItemContainerRevokers(itemContainerSafe);
itemContainerSafe.SetValue(s_ItemsViewItemContainerRevokersProperty, nullptr);
}
const bool removed = static_cast<bool>(m_itemContainersWithRevokers.erase(itemContainerRef));
MUX_ASSERT(removed);
RevokeItemsViewItemContainerRevokers(itemContainer);
itemContainer.SetValue(s_ItemsViewItemContainerRevokersProperty, nullptr);
m_itemContainersWithRevokers.erase(itemContainer);
}

void ItemsView::ClearAllItemsViewItemContainerRevokers() noexcept
{
for (const auto& itemContainerTracker : m_itemContainersWithRevokers)
for (const auto& itemContainer : m_itemContainersWithRevokers)
{
const auto& itemContainer = itemContainerTracker.safe_get();
// ClearAllItemsViewItemContainerRevokers is only called in the destructor, where exceptions cannot be thrown.
// If the associated ItemsView items have not yet been cleaned up, we must detach these revokers or risk a call into freed
// memory being made. However if they have been cleaned up these calls will throw. In this case we can ignore
// those exceptions.
if (itemContainer)
try
{
RevokeItemsViewItemContainerRevokers(itemContainer);
itemContainer.SetValue(s_ItemsViewItemContainerRevokersProperty, nullptr);
}
catch (...)
{
try
{
RevokeItemsViewItemContainerRevokers(itemContainer);
itemContainer.SetValue(s_ItemsViewItemContainerRevokersProperty, nullptr);
}
catch (...)
{
}
}
}
m_itemContainersWithRevokers.clear();
Expand Down
3 changes: 2 additions & 1 deletion controls/dev/ItemsView/ItemsView.h
Expand Up @@ -399,5 +399,6 @@ class ItemsView :
tracker_ref<winrt::UIElement> m_bringIntoViewElement{ this };

std::list<winrt::VirtualKey> m_navigationKeysToProcess;
std::set<tracker_ref<winrt::ItemContainer>> m_itemContainersWithRevokers;
std::set<winrt::ItemContainer> m_itemContainersWithRevokers;
std::map<winrt::ItemContainer, std::shared_ptr<PointerInfo<ItemsView>>> m_itemContainersPointerInfos;
};
17 changes: 5 additions & 12 deletions controls/dev/NavigationView/NavigationView.cpp
Expand Up @@ -3484,7 +3484,7 @@ void NavigationView::SetNavigationViewItemBaseRevokers(const winrt::NavigationVi
auto nvibRevokers = winrt::make_self<NavigationViewItemBaseRevokers>();
nvibRevokers->visibilityRevoker = RegisterPropertyChanged(nvib, winrt::UIElement::VisibilityProperty(), { this, &NavigationView::OnNavigationViewItemBaseVisibilityPropertyChanged });
nvib.SetValue(s_NavigationViewItemBaseRevokersProperty, nvibRevokers.as<winrt::IInspectable>());
m_itemsWithRevokerObjects.insert(tracker_ref<winrt::NavigationViewItemBase>{ this, nvib });
m_itemsWithRevokerObjects.insert(nvib);
}

void NavigationView::SetNavigationViewItemRevokers(const winrt::NavigationViewItem& nvi)
Expand All @@ -3503,22 +3503,15 @@ void NavigationView::SetNavigationViewItemRevokers(const winrt::NavigationViewIt

void NavigationView::ClearNavigationViewItemBaseRevokers(const winrt::NavigationViewItemBase& nvib)
{
const auto& nvibRef = tracker_ref<winrt::NavigationViewItemBase>{ this, nvib };
const auto& nvibSafe = nvibRef.safe_get();
if (nvibSafe)
{
RevokeNavigationViewItemBaseRevokers(nvibSafe);
nvibSafe.SetValue(s_NavigationViewItemBaseRevokersProperty, nullptr);
}
const bool removed = static_cast<bool>(m_itemsWithRevokerObjects.erase(nvibRef));
MUX_ASSERT(removed);
RevokeNavigationViewItemBaseRevokers(nvib);
nvib.SetValue(s_NavigationViewItemBaseRevokersProperty, nullptr);
m_itemsWithRevokerObjects.erase(nvib);
}

void NavigationView::ClearAllNavigationViewItemBaseRevokers() noexcept
{
for (const auto& nvibTracker : m_itemsWithRevokerObjects)
for (const auto& nvib : m_itemsWithRevokerObjects)
{
const auto& nvib = nvibTracker.safe_get();
// ClearAllNavigationViewItemBaseRevokers is only called in the destructor, where exceptions cannot be thrown.
// If the associated NV has not yet been cleaned up, we must detach these revokers or risk a call into freed
// memory being made. However if they have been cleaned up these calls will throw. In this case we can ignore
Expand Down
2 changes: 1 addition & 1 deletion controls/dev/NavigationView/NavigationView.h
Expand Up @@ -194,7 +194,7 @@ class NavigationView :
void ClearNavigationViewItemBaseRevokers(const winrt::NavigationViewItemBase& nvib);
void ClearAllNavigationViewItemBaseRevokers() noexcept;
void RevokeNavigationViewItemBaseRevokers(const winrt::NavigationViewItemBase& nvib);
std::set<tracker_ref<winrt::NavigationViewItemBase>> m_itemsWithRevokerObjects;
std::set<winrt::NavigationViewItemBase> m_itemsWithRevokerObjects;

void InvalidateTopNavPrimaryLayout();
// Measure functions for top navigation
Expand Down
48 changes: 48 additions & 0 deletions dxaml/xcp/core/animation/timer.cpp
Expand Up @@ -6,6 +6,11 @@
#include "Timemgr.h"
#include "TimeSpan.h"
#include <UIThreadScheduler.h>
#include "XamlTelemetry.h"
#include <FrameworkUdk/Containment.h>

// Bug 49537618: [1.5 servicing] DispatcherTimer callbacks are taking much longer on Cadmus
#define WINAPPSDK_CHANGEID_49537618 49537618

_Check_return_ HRESULT CDispatcherTimer::Create(
_Outptr_ CDependencyObject **ppObject,
Expand Down Expand Up @@ -85,6 +90,17 @@ _Check_return_ HRESULT CDispatcherTimer::ComputeStateImpl(
// If we've reached the point where the timer should fire, raise the event and start time over.
if (timeRemainingInMilliseconds <= 0)
{
if (WinAppSdk::Containment::IsChangeEnabled<WINAPPSDK_CHANGEID_49537618>())
{
TraceLoggingProviderWrite(
XamlTelemetry, "DispatcherTimer_Tick",
TraceLoggingUInt64(reinterpret_cast<uint64_t>(this), "ObjectPointer"),
TraceLoggingWideString(m_strName.GetBuffer(), "TimerName"),
TraceLoggingUInt64(static_cast<uint64_t>(m_pInterval->m_rTimeSpan * 1000.0), "IntervalInMilliseconds"),
TraceLoggingBoolean(!!m_pEventList, "HasListeners"),
TraceLoggingLevel(WINEVENT_LEVEL_VERBOSE));
}

FireTickEvent();

// Snap the time the DispatcherTimer ticked - the next interval is relative to this point.
Expand Down Expand Up @@ -167,6 +183,17 @@ _Check_return_ HRESULT CDispatcherTimer::Start()

m_rLastTickTime = pTimeManager->GetEstimatedNextTickTime();

if (WinAppSdk::Containment::IsChangeEnabled<WINAPPSDK_CHANGEID_49537618>())
{
TraceLoggingProviderWrite(
XamlTelemetry, "DispatcherTimer_Start",
TraceLoggingUInt64(reinterpret_cast<uint64_t>(this), "ObjectPointer"),
TraceLoggingWideString(m_strName.GetBuffer(), "TimerName"),
TraceLoggingUInt64(static_cast<uint64_t>(m_pInterval->m_rTimeSpan * 1000.0), "IntervalInMilliseconds"),
TraceLoggingUInt64(static_cast<uint64_t>(m_rLastTickTime * 1000.0), "StartTickTimeInMilliseconds"),
TraceLoggingLevel(WINEVENT_LEVEL_VERBOSE));
}

// Request a tick to update the timeline.
// The browser host and/or frame scheduler can be NULL during shutdown.
IXcpBrowserHost *pBH = core->GetBrowserHost();
Expand Down Expand Up @@ -198,6 +225,16 @@ _Check_return_ HRESULT CDispatcherTimer::Stop()
m_fAddedToManager = FALSE;
}

if (WinAppSdk::Containment::IsChangeEnabled<WINAPPSDK_CHANGEID_49537618>())
{
TraceLoggingProviderWrite(
XamlTelemetry, "DispatcherTimer_Stop",
TraceLoggingUInt64(reinterpret_cast<uint64_t>(this), "ObjectPointer"),
TraceLoggingWideString(m_strName.GetBuffer(), "TimerName"),
TraceLoggingUInt64(static_cast<uint64_t>(m_pInterval->m_rTimeSpan * 1000.0), "IntervalInMilliseconds"),
TraceLoggingLevel(WINEVENT_LEVEL_VERBOSE));
}

return S_OK;
}

Expand All @@ -216,6 +253,17 @@ _Check_return_ HRESULT CDispatcherTimer::WorkComplete()
m_fWorkPending = FALSE;
m_rLastTickTime = pTimeManager->GetEstimatedNextTickTime();

if (WinAppSdk::Containment::IsChangeEnabled<WINAPPSDK_CHANGEID_49537618>())
{
TraceLoggingProviderWrite(
XamlTelemetry, "DispatcherTimer_TickComplete",
TraceLoggingUInt64(reinterpret_cast<uint64_t>(this), "ObjectPointer"),
TraceLoggingWideString(m_strName.GetBuffer(), "TimerName"),
TraceLoggingUInt64(static_cast<uint64_t>(m_pInterval->m_rTimeSpan * 1000.0), "IntervalInMilliseconds"),
TraceLoggingUInt64(static_cast<uint64_t>(m_rLastTickTime * 1000.0), "StartTickTimeInMilliseconds"),
TraceLoggingLevel(WINEVENT_LEVEL_VERBOSE));
}

// Request a tick to update the timeline.
// The browser host and/or frame scheduler can be NULL during shutdown.
IXcpBrowserHost *pBH = core->GetBrowserHost();
Expand Down
79 changes: 59 additions & 20 deletions dxaml/xcp/core/compositor/RefreshAlignedClock.cpp
Expand Up @@ -3,6 +3,11 @@

#include "precomp.h"
#include "RefreshAlignedClock.h"
#include "XamlTelemetry.h"
#include <FrameworkUdk/Containment.h>

// Bug 49537618: [1.5 servicing] DispatcherTimer callbacks are taking much longer on Cadmus
#define WINAPPSDK_CHANGEID_49537618 49537618

//------------------------------------------------------------------------
//
Expand Down Expand Up @@ -78,6 +83,16 @@ RefreshAlignedClock::Tick()

m_lastReportedTime = GetNextTickTimeInSeconds();

if (WinAppSdk::Containment::IsChangeEnabled<WINAPPSDK_CHANGEID_49537618>())
{
TraceLoggingProviderWrite(
XamlTelemetry, "RefreshAlignedClock_Tick",
TraceLoggingUInt64(reinterpret_cast<uint64_t>(this), "ObjectPointer"),
TraceLoggingUInt64(static_cast<uint64_t>(m_lastReportedTime * 1000.0), "LastReportedTimeInMilliseconds"),
TraceLoggingUInt64(reinterpret_cast<uint64_t>(m_pIClock), "ClockPointer"),
TraceLoggingLevel(WINEVENT_LEVEL_VERBOSE));
}

return m_lastReportedTime;
}

Expand All @@ -93,31 +108,55 @@ RefreshAlignedClock::GetNextTickTimeInSeconds() const
{
auto guard = m_Lock.lock(); // can be called from ui thread + compositor thread simultaneously

XDOUBLE refreshIntervalInSeconds;

if (m_pRefreshRateInfo != NULL)
if (WinAppSdk::Containment::IsChangeEnabled<WINAPPSDK_CHANGEID_49537618>())
{
refreshIntervalInSeconds = static_cast<XDOUBLE>(m_pRefreshRateInfo->GetRefreshIntervalInMilliseconds()) / 1000.0;
double currentTime = m_pIClock->GetAbsoluteTimeInSeconds();

// Make sure time never flows backwards. If we calculated something less than the last reported time, just return
// the last reported time.
if (currentTime < m_lastReportedTime)
{
TraceLoggingProviderWrite(
XamlTelemetry, "RefreshAlignedClock_GetNextTickTimeInSeconds_TimeMovedBackwards",
TraceLoggingUInt64(reinterpret_cast<uint64_t>(this), "ObjectPointer"),
TraceLoggingUInt64(static_cast<uint64_t>(currentTime * 1000.0), "CurrentTimeInMilliseconds"),
TraceLoggingUInt64(static_cast<uint64_t>(m_lastReportedTime * 1000.0), "LastReportedTimeInMilliseconds"),
TraceLoggingUInt64(reinterpret_cast<uint64_t>(m_pIClock), "ClockPointer"),
TraceLoggingLevel(WINEVENT_LEVEL_VERBOSE));

currentTime = m_lastReportedTime;
}

return currentTime;
}
else
{
// The refresh rate can't be read from the system yet.
refreshIntervalInSeconds = static_cast<XDOUBLE>(DefaultRefreshIntervalInMilliseconds) / 1000.0;
XDOUBLE refreshIntervalInSeconds;

if (m_pRefreshRateInfo != NULL)
{
refreshIntervalInSeconds = static_cast<XDOUBLE>(m_pRefreshRateInfo->GetRefreshIntervalInMilliseconds()) / 1000.0;
}
else
{
// The refresh rate can't be read from the system yet.
refreshIntervalInSeconds = static_cast<XDOUBLE>(DefaultRefreshIntervalInMilliseconds) / 1000.0;
}

// Round time forward to the refresh rate interval.
XDOUBLE unroundedTime = static_cast<XDOUBLE>(m_pIClock->GetAbsoluteTimeInSeconds());
XDOUBLE roundedTime = static_cast<XDOUBLE>(XcpCeiling(unroundedTime / refreshIntervalInSeconds)) * refreshIntervalInSeconds;
XDOUBLE tolerance = 0.00001; // allow 0.01ms error

// Make sure we advance time by at least a frame each time the composition thread ticks.
if (roundedTime <= m_lastReportedTime + tolerance)
{
roundedTime = m_lastReportedTime + refreshIntervalInSeconds;
}

ASSERT(roundedTime > m_lastReportedTime);
return roundedTime;
}

// Round time forward to the refresh rate interval.
XDOUBLE unroundedTime = static_cast<XDOUBLE>(m_pIClock->GetAbsoluteTimeInSeconds());
XDOUBLE roundedTime = static_cast<XDOUBLE>(XcpCeiling(unroundedTime / refreshIntervalInSeconds)) * refreshIntervalInSeconds;
XDOUBLE tolerance = 0.00001; // allow 0.01ms error

// Make sure we advance time by at least a frame each time the composition thread ticks.
if (roundedTime <= m_lastReportedTime + tolerance)
{
roundedTime = m_lastReportedTime + refreshIntervalInSeconds;
}

ASSERT(roundedTime > m_lastReportedTime);
return roundedTime;
}

//------------------------------------------------------------------------
Expand Down
15 changes: 15 additions & 0 deletions dxaml/xcp/core/core/elements/DragEventArgs.cpp
Expand Up @@ -6,6 +6,11 @@
#include "Activators.g.h"

#include <WRLHelper.h>
#include <FrameworkUdk/Containment.h>

// Bug 49668748: [1.5 Servicing] After dragging an FE Home item, all item drops on breadcrumbs don't support Move after first drag
#define LOCAL_WINAPPSDK_CHANGEID_49668748 49668748


// Initialize the DragEventArgs with any framework specific context.
_Check_return_ HRESULT CDragEventArgs::Create(_In_ CCoreServices* pCore, _Outptr_ CDragEventArgs** ppArgs, _In_opt_ IInspectable* pWinRtDragInfo, _In_opt_ IInspectable* pDragDropAsyncOperation)
Expand All @@ -19,6 +24,16 @@ _Check_return_ HRESULT CDragEventArgs::Create(_In_ CCoreServices* pCore, _Outptr
if(pWinRtDragInfo)
{
IFC_RETURN(spArgs->m_spWinRtDragInfo.reset(pWinRtDragInfo));
if (WinAppSdk::Containment::IsChangeEnabled<LOCAL_WINAPPSDK_CHANGEID_49668748>())
{
wrl::ComPtr<mui::DragDrop::IDragInfo> dragInfo;
if (SUCCEEDED(pWinRtDragInfo->QueryInterface(IID_PPV_ARGS(&dragInfo))))
{
wadt::DataPackageOperation allowedOperations;
IFC_RETURN(dragInfo->get_AllowedOperations(&allowedOperations));
IFC_RETURN(spArgs->put_AllowedOperations(static_cast<DirectUI::DataPackageOperation>(allowedOperations)));
}
}
}

if(pDragDropAsyncOperation)
Expand Down

0 comments on commit b91b3ce

Please sign in to comment.