[core] Do not make pending requests for already requested images.
so that processing for the corresponding tile does not suspend and the rendering performance is not affected.
This commit is contained in:
@@ -197,16 +197,13 @@ void ImageManager::checkMissingAndNotify(ImageRequestor& requestor, const ImageR
|
||||
existingRequestors.emplace(requestorPtr);
|
||||
continue;
|
||||
}
|
||||
// Unlike icons, pattern changes are not caught
|
||||
// with style-diff meaning that the existing request
|
||||
// could be from the previous style and we cannot
|
||||
// coalesce requests for them.
|
||||
if (dependency.second != ImageType::Pattern) {
|
||||
continue;
|
||||
}
|
||||
// The request for this image has been already delivered
|
||||
// to the client, so we do not treat it as pending.
|
||||
existingRequestors.emplace(requestorPtr);
|
||||
} else {
|
||||
requestedImages[missingImage].emplace(requestorPtr);
|
||||
requestor.addPendingRequest(missingImage);
|
||||
}
|
||||
requestedImages[missingImage].emplace(requestorPtr);
|
||||
requestor.addPendingRequest(missingImage);
|
||||
|
||||
auto removePendingRequests = [this, missingImage] {
|
||||
auto existingRequest = requestedImages.find(missingImage);
|
||||
|
||||
@@ -187,20 +187,14 @@ TEST(ImageManager, OnStyleImageMissingBeforeSpriteLoaded) {
|
||||
EXPECT_EQ(observer.count, 1);
|
||||
ASSERT_TRUE(notified);
|
||||
|
||||
// Repeated request of the same image shall not result another
|
||||
// `ImageManagerObserver.onStyleImageMissing()` call.
|
||||
imageManager.getImages(requestor, std::make_pair(dependencies, ++imageCorrelationID));
|
||||
runLoop.runOnce();
|
||||
|
||||
EXPECT_EQ(observer.count, 1);
|
||||
|
||||
// Request for updated dependencies must be dispatched to the
|
||||
// observer.
|
||||
dependencies.emplace("post", ImageType::Icon);
|
||||
imageManager.getImages(requestor, std::make_pair(dependencies, ++imageCorrelationID));
|
||||
runLoop.runOnce();
|
||||
ASSERT_TRUE(requestor.hasPendingRequests());
|
||||
|
||||
EXPECT_EQ(observer.count, 2);
|
||||
runLoop.runOnce();
|
||||
ASSERT_FALSE(requestor.hasPendingRequests());
|
||||
|
||||
// Another requestor shall not have pending requests for already obtained images.
|
||||
StubImageRequestor anotherRequestor(imageManager);
|
||||
|
||||
Reference in New Issue
Block a user