Skip to content

[WPE] Increased memory consumption of WebProcess during regular video…#1449

Merged
magomez merged 1 commit intowpe-2.38from
pgorszkowski/2.38/WPE-Increased-memory-consumption-of-WebProcess-during-regular-video-playback-and-RWI
Jan 23, 2025
Merged

[WPE] Increased memory consumption of WebProcess during regular video…#1449
magomez merged 1 commit intowpe-2.38from
pgorszkowski/2.38/WPE-Increased-memory-consumption-of-WebProcess-during-regular-video-playback-and-RWI

Conversation

@pgorszkowski-igalia
Copy link
Copy Markdown

@pgorszkowski-igalia pgorszkowski-igalia commented Jan 23, 2025

… playback and RWI

https://bugs.webkit.org/show_bug.cgi?id=284108

Reviewed by Devin Rousso.

When WebInspector is used, the downloaded data is cached also for it in NetworkResourcesData. The single resource data cannot be greater than maximumSingleResourceContentSize (50MB) and the total size of resources content cannot be greater than maximumResourcesContentSize (200MB). At the end of downloading the resource, the binary data is decoded to the string represantation (base64 or other depends on decoder). Decoding process can increased the size of the kept resource data. The limit maximumSingleResourceContentSize is checked but maximumResourcesContentSize limit is not checked which can lead to situation that m_contentSize (the total size of resources content) is greater than maximumResourcesContentSize. This causes that condition checked in NetworkResourcesData::ensureFreeSpace is invalid because subtraction unsigned values where first value(minuend) is smaller than the second one(subtrahend) gives a huge number (instead of negative number).

This change ensures that after decoding binary data into string representation the total size of resources content (m_contentSize) is not greater than maximumResourcesContentSize. The assert is added in NetworkResourcesData::ensureFreeSpace to check that m_contentSize is not greater than maximumResourcesContentSize.

I fixed implementation of function NetworkResourcesData::clear in case passing the preservedLoaderId. In that case we should update m_requestIdsDeque and m_contentSize and not just clear them.

Additionally I changed the type of m_requestIdsDeque from Deque to ListHashSet. This change fixes adding to m_requestIdsDeque the same requestId many times.

  • Source/WebCore/inspector/NetworkResourcesData.cpp: (WebCore::NetworkResourcesData::ResourceData::decodeDataToContent): (WebCore::NetworkResourcesData::setResourceContent): (WebCore::NetworkResourcesData::maybeAddResourceData): (WebCore::NetworkResourcesData::maybeDecodeDataToContent): (WebCore::NetworkResourcesData::clear):
    (WebCore::NetworkResourcesData::ensureFreeSpace):
  • Source/WebCore/inspector/NetworkResourcesData.h:

Canonical link: https://commits.webkit.org/289143@main

2b42028

Build-Tests Layout-Tests
✅ 🛠 wpe-238-amd64-build 🧪 wpe-238-amd64-layout
✅ 🛠 wpe-238-arm32-build 🧪 wpe-238-arm32-layout

… playback and RWI

https://bugs.webkit.org/show_bug.cgi?id=284108

Reviewed by Devin Rousso.

When WebInspector is used, the downloaded data is cached also for it in NetworkResourcesData.
The single resource data cannot be greater than maximumSingleResourceContentSize (50MB) and
the total size of resources content cannot be greater than maximumResourcesContentSize (200MB).
At the end of downloading the resource, the binary data is decoded to the string represantation
(base64 or other depends on decoder). Decoding process can increased the size of the kept resource
data. The limit maximumSingleResourceContentSize is checked but maximumResourcesContentSize limit
is not checked which can lead to situation that m_contentSize (the total size of resources content)
is greater than maximumResourcesContentSize. This causes that condition checked in
NetworkResourcesData::ensureFreeSpace is invalid because subtraction unsigned values where
first value(minuend) is smaller than the second one(subtrahend) gives a huge number (instead of
negative number).

This change ensures that after decoding binary data into string representation the total size of
resources content (m_contentSize) is not greater than maximumResourcesContentSize. The assert is
added in NetworkResourcesData::ensureFreeSpace to check that m_contentSize is not greater than
maximumResourcesContentSize.

I fixed implementation of function NetworkResourcesData::clear in case passing the preservedLoaderId.
In that case we should update m_requestIdsDeque and m_contentSize and not just clear them.

Additionally I changed the type of m_requestIdsDeque from Deque<String> to ListHashSet<String>.
This change fixes adding to m_requestIdsDeque the same requestId many times.

* Source/WebCore/inspector/NetworkResourcesData.cpp:
(WebCore::NetworkResourcesData::ResourceData::decodeDataToContent):
(WebCore::NetworkResourcesData::setResourceContent):
(WebCore::NetworkResourcesData::maybeAddResourceData):
(WebCore::NetworkResourcesData::maybeDecodeDataToContent):
(WebCore::NetworkResourcesData::clear):
(WebCore::NetworkResourcesData::ensureFreeSpace):
* Source/WebCore/inspector/NetworkResourcesData.h:

Canonical link: https://commits.webkit.org/289143@main
@magomez magomez merged commit 555a392 into wpe-2.38 Jan 23, 2025
@magomez magomez deleted the pgorszkowski/2.38/WPE-Increased-memory-consumption-of-WebProcess-during-regular-video-playback-and-RWI branch January 23, 2025 12:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Development

Successfully merging this pull request may close these issues.

2 participants