When the Caches/WebKit/ServiceWorkers folder is not writable, the Safari Networking process has very high CPU usage (near 100%), due to logging error messages nonstop.
Steps to reproduce:
1) Delete the contents of the folder ~/Library/Containers/com.apple.Safari/Data/Library/Caches
2) Lock the folder ~/Library/Containers/com.apple.Safari/Data/Library/Caches in Finder
3) Launch Safari
4) Open https://www.youtube.com
5) Play a video
6) Launch Activity Monitor and view % CPU
7) Launch Console and view messages
I found the problem by also noticing the "logd" process high in Activity Monitor, which inspired me to check the Console log. I saw the following errors over and over again:
com.apple.WebKit.Networking os_unix.c:44500: (2) open(/Users/bigsir/Library/Containers/com.apple.Safari/Data/Library/Caches/WebKit/ServiceWorkers/ServiceWorkerRegistrations-5.sqlite3) - No such file or directory
com.apple.WebKit.Networking Failed to open Service Worker registration database
com.apple.WebKit.Networking cannot open file at line 44499 of [02c344acea]
I've reproduced this issue with macOS 11.1 (20C69) and Safari 14.0.2 (16610.3.7.1.9) on an Apple silicon Mac mini, and also with macOS 10.14.6 (18G7016) on an Intel MacBook Pro.
I had locked the Safari Caches folder because it tends to get enormous on disk for no good reason. I don't need or want anything to be cached on disk after I quit Safari.
I think that this is something we'd consider to be unsupported configuration, but CC'ing other folks for their perspectives.
> I had locked the Safari Caches folder because it tends to get enormous on
> disk for no good reason. I don't need or want anything to be cached on disk
> after I quit Safari.
Why not using Safari private windows?
(In reply to Alexey Proskuryakov from comment #1)
> I think that this is something we'd consider to be unsupported
> configuration, but CC'ing other folks for their perspectives.
I tend to agree, though it should not be too difficult to fix.
> Why not using Safari private windows?
Some people including myself would like private browsing by default. However, Safari has several barriers to this. For example, there is no Private Window option in the "New windows open with" preference. Also, the ⌘n keyboard shortcut cannot be successfully redefined to New Private Window in System Preferences, Keyboard, Shortcuts.
> it should not be too difficult to fix.
This was the hope. It may be unsupported, but perhaps this bug reveals that the architecture of the underlying code is a bit problematic.
Created attachment 417268 [details]
Comment on attachment 417268 [details]
test failure is unrelated
Committed r271404: <https://trac.webkit.org/changeset/271404>
All reviewed patches have been landed. Closing bug and clearing flags on attachment 417268 [details].