Bug 181546 - WKWebView.ClearAppCache is a flaky API test failure on High Sierra.
Summary: WKWebView.ClearAppCache is a flaky API test failure on High Sierra.
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: Chris Dumez
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2018-01-11 11:21 PST by Matt Lewis
Modified: 2018-03-19 19:34 PDT (History)
8 users (show)

See Also:


Attachments
Patch (2.06 KB, patch)
2018-03-19 15:55 PDT, Chris Dumez
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Matt Lewis 2018-01-11 11:21:12 PST
WKWebView.ClearAppCache is a flaky API failure on High Sierra.

build:
https://build.webkit.org/builders/Apple%20High%20Sierra%20Release%20WK1%20(Tests)/builds/2565/steps/run-api-tests/logs/stdio
https://build.webkit.org/builders/Apple%20High%20Sierra%20Release%20WK1%20(Tests)/builds/2565

Error in log:

FAIL WKWebView.ClearAppCache

/Volumes/Data/slave/highsierra-release/build/Tools/TestWebKitAPI/Tests/WebKitCocoa/LocalStorageClear.mm:183
Value of: 1ul
  Actual: 1
Expected: websiteDataRecords.count
Which is: 2


/Volumes/Data/slave/highsierra-release/build/Tools/TestWebKitAPI/Tests/WebKitCocoa/LocalStorageClear.mm:185
Value of: [record.displayName UTF8String]
  Actual: "Local documents on your computer"
Expected: "127.0.0.1"


/Volumes/Data/slave/highsierra-release/build/Tools/TestWebKitAPI/Tests/WebKitCocoa/LocalStorageClear.mm:187
Value of: [type UTF8String]
  Actual: "WKWebsiteDataTypeLocalStorage"
Expected: [WKWebsiteDataTypeOfflineWebApplicationCache UTF8String]
Which is: "WKWebsiteDataTypeOfflineWebApplicationCache"


I was able to reproduce the failure locally by running this twice:
run-api-tests --debug WKWebView --verbose

The crash claimed it to be a simulated crash.
Comment 1 Radar WebKit Bug Importer 2018-01-11 11:22:21 PST
<rdar://problem/36444327>
Comment 2 Alexey Proskuryakov 2018-01-11 20:13:40 PST
I believe that we've been seeing it very frequently on El Capitan as well.
Comment 3 Chris Dumez 2018-03-19 14:59:19 PDT
(In reply to Alexey Proskuryakov from comment #2)
> I believe that we've been seeing it very frequently on El Capitan as well.

The type of data that remains is localStorage. It remains after the initial call to remove all data :/
Comment 4 Chris Dumez 2018-03-19 15:25:31 PDT
LocalStorageDatabaseTracker::deleteDatabasesModifiedSince() chooses not to delete file__0 because it is not able to compute the last modified time for path:
/Users/chris/Library/WebKit/TestWebKitAPI/WebsiteData/LocalStorage/file__0.localstorage
Comment 5 Chris Dumez 2018-03-19 15:26:15 PDT
(In reply to Chris Dumez from comment #4)
> LocalStorageDatabaseTracker::deleteDatabasesModifiedSince() chooses not to
> delete file__0 because it is not able to compute the last modified time for
> path:
> /Users/chris/Library/WebKit/TestWebKitAPI/WebsiteData/LocalStorage/file__0.
> localstorage

/Users/chris/Library/WebKit/TestWebKitAPI/WebsiteData/LocalStorage/file__0.localstorage
does not exist on my machine but I have /Users/chris/Library/WebKit/TestWebKitAPI/WebsiteData/LocalStorage/file__0.localstorage-wal !
Comment 6 Chris Dumez 2018-03-19 15:35:02 PDT
I suspect it could be related to LocalStorageDatabaseTracker::deleteAllDatabases() using FileSystem::deleteFile() instead of SQLiteFileSystem::deleteDatabaseFile().
Comment 7 Chris Dumez 2018-03-19 15:39:46 PDT
(In reply to Chris Dumez from comment #6)
> I suspect it could be related to
> LocalStorageDatabaseTracker::deleteAllDatabases() using
> FileSystem::deleteFile() instead of SQLiteFileSystem::deleteDatabaseFile().

Not it, LocalStorageDatabaseTracker::deleteAllDatabases() appears to be unused.
Comment 8 Chris Dumez 2018-03-19 15:41:33 PDT
Looks like we correctly use SQLiteFileSystem::deleteDatabaseFile() in all places. So I suspect the issue could be that we are deleting database files while the database is still open. I guess Sqlite could end up later writing a -wal file as a result.
Comment 9 Chris Dumez 2018-03-19 15:43:42 PDT
e.g. LocalStorageDatabaseTracker::removeDatabaseWithOriginIdentifier() seems to delete the database file while it is open.
Comment 10 Chris Dumez 2018-03-19 15:55:28 PDT
Created attachment 336082 [details]
Patch
Comment 11 WebKit Commit Bot 2018-03-19 19:34:29 PDT
Comment on attachment 336082 [details]
Patch

Clearing flags on attachment: 336082

Committed r229736: <https://trac.webkit.org/changeset/229736>
Comment 12 WebKit Commit Bot 2018-03-19 19:34:31 PDT
All reviewed patches have been landed.  Closing bug.