0

Increase bitmap deserialization limits in mojom transfer

The change https://crrev.com/c/2368484 introduced bitmap limits while
deserializing the bitmap data in mojom transfer. This regressed large
bitmap transfers b/n the processes which used to work before
(Ex: Navigator.clipboard.write)

The limits were chosen arbitrarily to validate that the image isn't
incredibly large due to any programming error, but 32k is not a fair
limit. Increase the limit to 64k which can accommodate images from the
largest possible canvas(64k is the canvas max possible dimension)

Bug: 1142852
Change-Id: I7c6b32d8ac8549b9053178d477e7c7610add3f3f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2504012
Reviewed-by: Greg Kerr <kerrnel@chromium.org>
Reviewed-by: James Cook <jamescook@chromium.org>
Reviewed-by: Ken Rockot <rockot@google.com>
Reviewed-by: Mike Klein <mtklein@google.com>
Commit-Queue: Akhila Veerapuraju <dhveerap@microsoft.com>
Cr-Commit-Position: refs/heads/master@{#821750}
This commit is contained in:
Akhila Veerapuraju
2020-10-28 16:45:22 +00:00
committed by Commit Bot
parent 1c5d9e6dce
commit 6098e4e89a
2 changed files with 7 additions and 5 deletions

@ -10,9 +10,11 @@ namespace mojo {
namespace {
// Maximum reasonable width and height. We don't try to deserialize bitmaps
// bigger than these dimensions. Arbitrarily chosen.
constexpr int kMaxWidth = 32 * 1024;
constexpr int kMaxHeight = 32 * 1024;
// bigger than these dimensions.
// These limits are fairly large to accommodate images from the largest possible
// canvas.
constexpr int kMaxWidth = 64 * 1024;
constexpr int kMaxHeight = 64 * 1024;
// A custom SkPixelRef subclass to wrap a BigBuffer storing the pixel data.
class BigBufferPixelRef final : public SkPixelRef {

@ -87,7 +87,7 @@ TEST(StructTraitsTest, Bitmap) {
TEST(StructTraitsTest, BitmapTooWideToSerialize) {
SkBitmap input;
constexpr int kTooWide = 32 * 1024 + 1;
constexpr int kTooWide = 64 * 1024 + 1;
input.allocPixels(
SkImageInfo::MakeN32(kTooWide, 1, SkAlphaType::kUnpremul_SkAlphaType));
input.eraseColor(SK_ColorYELLOW);
@ -98,7 +98,7 @@ TEST(StructTraitsTest, BitmapTooWideToSerialize) {
TEST(StructTraitsTest, BitmapTooTallToSerialize) {
SkBitmap input;
constexpr int kTooTall = 32 * 1024 + 1;
constexpr int kTooTall = 64 * 1024 + 1;
input.allocPixels(
SkImageInfo::MakeN32(1, kTooTall, SkAlphaType::kUnpremul_SkAlphaType));
input.eraseColor(SK_ColorYELLOW);