Bug 232067 - FileSystemSyncAccessHandle should close platform file handle on close()
Summary: FileSystemSyncAccessHandle should close platform file handle on close()
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Sihui Liu
URL:
Keywords: InRadar
Depends on:
Blocks: 231706
  Show dependency treegraph
 
Reported: 2021-10-21 01:05 PDT by Sihui Liu
Modified: 2021-10-26 14:38 PDT (History)
6 users (show)

See Also:


Attachments
Patch (12.61 KB, patch)
2021-10-21 01:08 PDT, Sihui Liu
no flags Details | Formatted Diff | Diff
Patch (18.35 KB, patch)
2021-10-21 08:27 PDT, Sihui Liu
no flags Details | Formatted Diff | Diff
Patch (19.99 KB, patch)
2021-10-21 12:00 PDT, Sihui Liu
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Sihui Liu 2021-10-21 01:05:28 PDT
...
Comment 1 Sihui Liu 2021-10-21 01:08:48 PDT
Created attachment 441994 [details]
Patch
Comment 2 Sihui Liu 2021-10-21 08:27:17 PDT
Created attachment 442028 [details]
Patch
Comment 3 youenn fablet 2021-10-21 09:17:52 PDT
Comment on attachment 442028 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=442028&action=review

> Source/WebCore/Modules/filesystemaccess/FileSystemSyncAccessHandle.cpp:53
>          m_source->close(m_identifier, [](auto) { });

We should probably also make sure we close also if ScriptExecutionContext is stopped. Normally there should be no issue but it does not hurt to close sooner rather than later.

> Source/WebCore/Modules/filesystemaccess/FileSystemSyncAccessHandle.cpp:100
> +    if (m_state == State::Closing)

Why do we need the Closing state?
It seems only useful for the promise rejection message.
I am not sure this is worth the effort.

> Source/WebCore/Modules/filesystemaccess/FileSystemSyncAccessHandle.cpp:130
> +        return Exception { InvalidStateError, "AccessHandle is being closed or closed"_s };

I would write it as "AccessHandle is closing or closed" or "AccessHandle is not active".

> LayoutTests/imported/w3c/web-platform-tests/file-system-access/sandboxed_FileSystemSyncAccessHandle-close.https.tentative.worker-expected.txt:4
> +FAIL SyncAccessHandle.read fails after SyncAccessHandle.close settles promise_test: Unhandled rejection with value: object "InvalidStateError: AccessHandle is closed"

Why are we failing those tests? Are we missing something to be able to run properly sync_access_handle_test.
It would seem worthwhile to make sure we run these tests properly.
Comment 4 Sihui Liu 2021-10-21 09:32:34 PDT
(In reply to youenn fablet from comment #3)
> Comment on attachment 442028 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=442028&action=review
> 
> > Source/WebCore/Modules/filesystemaccess/FileSystemSyncAccessHandle.cpp:53
> >          m_source->close(m_identifier, [](auto) { });
> 
> We should probably also make sure we close also if ScriptExecutionContext is
> stopped. Normally there should be no issue but it does not hurt to close
> sooner rather than later.

Yeah I will follow up in a separate bugs, filed https://bugs.webkit.org/show_bug.cgi?id=231250 before. 

> 
> > Source/WebCore/Modules/filesystemaccess/FileSystemSyncAccessHandle.cpp:100
> > +    if (m_state == State::Closing)
> 
> Why do we need the Closing state?
> It seems only useful for the promise rejection message.
> I am not sure this is worth the effort.

Will remove.

> 
> > Source/WebCore/Modules/filesystemaccess/FileSystemSyncAccessHandle.cpp:130
> > +        return Exception { InvalidStateError, "AccessHandle is being closed or closed"_s };
> 
> I would write it as "AccessHandle is closing or closed" or "AccessHandle is
> not active".

Sure.

> 
> > LayoutTests/imported/w3c/web-platform-tests/file-system-access/sandboxed_FileSystemSyncAccessHandle-close.https.tentative.worker-expected.txt:4
> > +FAIL SyncAccessHandle.read fails after SyncAccessHandle.close settles promise_test: Unhandled rejection with value: object "InvalidStateError: AccessHandle is closed"
> 
> Why are we failing those tests? Are we missing something to be able to run
> properly sync_access_handle_test.
> It would seem worthwhile to make sure we run these tests properly.

I don't think we are missing things for this test. I will adjust the implementation to match the test expectation.
Comment 5 Radar WebKit Bug Importer 2021-10-21 11:47:41 PDT
<rdar://problem/84517013>
Comment 6 Sihui Liu 2021-10-21 12:00:54 PDT
Created attachment 442055 [details]
Patch
Comment 7 EWS 2021-10-21 16:13:10 PDT
Committed r284652 (243372@main): <https://commits.webkit.org/243372@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 442055 [details].