Bug 264971

Summary: ScriptBuffer append with empty string adds empty segment
Product: WebKit Reporter: Cristian Linte <ioancris>
Component: WebCore JavaScriptAssignee: Mark Lam <mark.lam>
Status: RESOLVED FIXED    
Severity: Normal CC: jean-yves.avenard, mark.lam, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Local Build   
Hardware: Unspecified   
OS: Unspecified   

Cristian Linte
Reported 2023-11-16 11:58:59 PST
ScriptBufferSourceProvider sometimes receives a ScriptBuffer with 2 data segments where 2nd segment is empty (size 0, buffer null). The 2nd empty segment was likely added in WorkerScriptLoader::didFinishLoading by append(decoder->flush()) where flush can return an empty string. ScriptBufferSourceProvider will call makeContiguous on scriptBuffer which for the above case end up making an unnecessary copy and this memory is kept alive by ScriptBufferSourceProvider thus increasing memory usage. ScriptBuffer should not add an empty segment to the buffer when append is called with empty string.
Attachments
Radar WebKit Bug Importer
Comment 1 2023-11-23 11:59:14 PST
Mark Lam
Comment 2 2023-11-23 13:32:15 PST
EWS
Comment 3 2023-11-29 07:03:26 PST
Committed 271275@main (d445ae96c998): <https://commits.webkit.org/271275@main> Reviewed commits have been landed. Closing PR #20855 and removing active labels.
Note You need to log in before you can comment on or make changes to this bug.