Repository navigation
fix: correct VectorCache capacity and CacheHolder instance pooling - #3361
Merged
Merged
Conversation
…ssues and improve style rendering fallback
…anding of layer management
…and global configuration
…rkflows and global configuration" This reverts commit f4384f5.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Two bugs in the
VectorCache/CacheHoldercaching infrastructure that together made the vector cache completely non-functional.Bug 1 —
Math.MininVectorCachecapped capacity to 1VectorCache.csusedMath.Min(capacity, 1)when constructing theLruCache. SinceMath.Min(30000, 1) == 1, the cache could only ever hold a single entry regardless of the configured capacity. Any frame with more than one unique key caused constant eviction and recreation of Skia objects.Fix: Changed to
Math.Max(capacity, 1)so the configured capacity is honored and only a floor of 1 is enforced.Bug 2 —
CacheHolder.Get<T>()didn't passthistoCacheTrackerCacheHolder.Get<TResult>()returnednew CacheTracker<TResult>((TResult)temp)— the single-argument constructor that leaves_holder == null. When the caller disposed theCacheTracker,Dispose()saw_holder == nulland calledDisposeIfDisposable(), destroying the Skia resource outright instead of returning it to the holder. Subsequent lookups for the same key found aCacheHolderwith_instance == null, fell through to the uncached fallback, and created a fresh object every time.Fix: Changed to
new CacheTracker<TResult>(this, (TResult)temp)so the holder reference is preserved andDispose()correctly returns the instance viaSetInstance.Impact
With both bugs present the cache was effectively a no-op: every render frame recreated all
SKPath,SKPaint,SKTypeface, and label-bitmap objects from scratch. Layers with many features (lines, polygons, labels) would see O(N features) allocations per frame instead of O(distinct styles). Label layers were worst affected becauseCreateLabelAsBitmaprenders a small bitmap per unique label text.Relates to #3328