Bug 1448091 part 2: AccessibleHandler: Don't repeatedly and unnecessarily refresh the cache after the first change. r?MarcoZ
The singleton AccessibleHandlerControl maintains a global cache generation counter which is incremented whenever any node is changed.
The handler for each node tracks the cache generation at the time its cache was initialized.
To check whether the cache needs to be updated, the handler compares its generation against the global generation from AccessibleHandlerControl.
If they differ, it refreshes the cache.
Previously, the handler didn't update its cache generation after refreshing.
This meant that every single query after the first change would refresh the whole cache, even if there wasn't a second change.
This resulted in a huge number of wasted cache updates for clients such as JAWS which hold onto accessibles, rather than releasing them and fetching them again for each update.
MozReview-Commit-ID: 80d4n1cIjzQ
--- a/accessible/ipc/win/handler/AccessibleHandler.cpp
+++ b/accessible/ipc/win/handler/AccessibleHandler.cpp
@@ -202,24 +202,31 @@ AccessibleHandler::MaybeUpdateCachedData
{
RefPtr<AccessibleHandlerControl> ctl(gControlFactory.GetOrCreateSingleton());
if (!ctl) {
return E_OUTOFMEMORY;
}
uint32_t gen = ctl->GetCacheGen();
if (gen == mCacheGen) {
+ // Cache is already up to date.
return S_OK;
}
if (!mCachedData.mGeckoBackChannel) {
return E_POINTER;
}
- return mCachedData.mGeckoBackChannel->Refresh(&mCachedData.mDynamicData);
+ HRESULT hr = mCachedData.mGeckoBackChannel->Refresh(&mCachedData.mDynamicData);
+ if (SUCCEEDED(hr)) {
+ // We just updated the cache, so update this object's cache generation
+ // so we only update the cache again after the next change.
+ mCacheGen = gen;
+ }
+ return hr;
}
HRESULT
AccessibleHandler::GetAllTextInfo(BSTR* aText)
{
MOZ_ASSERT(mCachedData.mGeckoBackChannel);
ClearTextCache();