Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: f280a9ac58cc5ee245d50ee11bec2069356f3804
      
https://github.com/WebKit/WebKit/commit/f280a9ac58cc5ee245d50ee11bec2069356f3804
  Author: Chris Dumez <[email protected]>
  Date:   2026-07-28 (Tue, 28 Jul 2026)

  Changed paths:
    M Source/WebKit/NetworkProcess/storage/FileSystemStorageHandle.cpp
    M Tools/TestWebKitAPI/Tests/WebKit/WKWebView/FileSystemAccess.mm

  Log Message:
  -----------
  OPFS FileSystemWritableFileStream quota accounting over-charges positioned 
writes
https://bugs.webkit.org/show_bug.cgi?id=320355

Reviewed by Sihui Liu.

FileSystemStorageHandle::computeCommandSpace() estimated the disk space a
write command would consume by seeking from FileSeekOrigin::Current, but the
write itself (executeCommandForWritableInternal) and the Seek command both
interpret the command's position as an absolute offset from the start of the
file (FileSeekOrigin::Beginning). Because the two used different seek origins,
the space estimate was wrong whenever the writable stream's file offset was
non-zero: computeCommandSpace() based finalSize on (currentOffset + position)
instead of just (position).

The estimate was always too large (the current offset is never negative), so
the code requested more quota than the write actually consumed. This could
spuriously deny an otherwise-valid write with QuotaError and inflate the
origin's tracked usage until the next usage re-measurement. It triggered even
for the common "overwrite in place" pattern (repeated writes at position 0),
because each write advances the file offset.

Fix computeCommandSpace() to compute the write's end offset the same way the
write does: use the command's position directly when present, otherwise query
the current file offset non-destructively via seek(0, Current). This also
removes the previous side effect of moving the file offset inside a helper
that is only meant to compute a size.

Add an API test that writes a chunk to advance the file offset and then
overwrites it in place at position 0 under a small origin quota. Before the
fix, the positioned write was charged (currentOffset + position + length) and
was spuriously denied with QuotaExceededError.

* Source/WebKit/NetworkProcess/storage/FileSystemStorageHandle.cpp:
(WebKit::FileSystemStorageHandle::computeCommandSpace):
* Tools/TestWebKitAPI/Tests/WebKit/WKWebView/FileSystemAccess.mm:
(TEST(FileSystemAccess, WritableQuotaAccountingForPositionedWrite)):

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



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications

Reply via email to