[Impeller] test empty snapshot and allocation failure. (#164668)
Speculative fix for https://github.com/flutter/flutter/issues/164628 If our render target allocation failed, we need to bail out of toImage so that we don't crash. Adds a test that simulates this by asking for a 0x0 texture.
This commit is contained in:
@@ -21,10 +21,12 @@
|
||||
#include "flutter/testing/testing.h"
|
||||
#include "fml/synchronization/count_down_latch.h"
|
||||
#include "imgui.h"
|
||||
#include "impeller/base/validation.h"
|
||||
#include "impeller/core/device_buffer.h"
|
||||
#include "impeller/core/device_buffer_descriptor.h"
|
||||
#include "impeller/core/formats.h"
|
||||
#include "impeller/core/texture_descriptor.h"
|
||||
#include "impeller/display_list/aiks_context.h"
|
||||
#include "impeller/display_list/dl_dispatcher.h"
|
||||
#include "impeller/display_list/dl_image_impeller.h"
|
||||
#include "impeller/geometry/scalar.h"
|
||||
@@ -1104,5 +1106,18 @@ TEST_P(AiksTest, ToImageFromImage) {
|
||||
OpenPlaygroundHere(canvas.Build());
|
||||
}
|
||||
|
||||
TEST_P(AiksTest, DisplayListToTextureAllocationFailure) {
|
||||
ScopedValidationDisable disable_validations;
|
||||
DisplayListBuilder builder;
|
||||
|
||||
AiksContext aiks_context(GetContext(), nullptr);
|
||||
// Use intentionally invalid dimensions that would trigger an allocation
|
||||
// failure.
|
||||
auto texture =
|
||||
DisplayListToTexture(builder.Build(), ISize{0, 0}, aiks_context);
|
||||
|
||||
EXPECT_EQ(texture, nullptr);
|
||||
}
|
||||
|
||||
} // namespace testing
|
||||
} // namespace impeller
|
||||
|
||||
@@ -1309,6 +1309,9 @@ std::shared_ptr<Texture> DisplayListToTexture(
|
||||
kDefaultColorAttachmentConfig // color_attachment_config
|
||||
);
|
||||
}
|
||||
if (!target.IsValid()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
SkIRect sk_cull_rect = SkIRect::MakeWH(size.width, size.height);
|
||||
impeller::FirstPassDispatcher collector(
|
||||
|
||||
@@ -58,7 +58,7 @@ sk_sp<DlImage> DoMakeRasterSnapshot(
|
||||
const sk_sp<DisplayList>& display_list,
|
||||
SkISize size,
|
||||
const SnapshotController::Delegate& delegate) {
|
||||
// Ensure that the current thread has a rendering context. This must be done
|
||||
// Ensure that the current thread has a rendering context. This must be done
|
||||
// before calling GetAiksContext because constructing the AiksContext may
|
||||
// invoke graphics APIs.
|
||||
std::unique_ptr<Surface> pbuffer_surface;
|
||||
|
||||
Reference in New Issue
Block a user