Aldaviva / VivaldiCustomLauncher

🎻 Intercept executions of Vivaldi to add custom arguments and apply tweaks files
Apache License 2.0
6 stars 1 forks source link

After installing a Vivaldi update, Junk E-mail folder classification tweak takes three Vivaldi restarts to take effect instead of two #4

Closed Aldaviva closed 2 years ago

Aldaviva commented 2 years ago

Normal Vivaldi update installation takes two restarts for tweaks to take effect:

  1. One restart by the Vivaldi installer to apply the update
  2. One restart by VivaldiCustomLauncher to apply tweaks

Most of the tweaks are getting successfully applied after the second restart, but the background-common-bundle.js tweak that converts the Junk E-mail folder from a spam folder into a normal folder consistently does not take effect. It takes one extra restart for this tweak to make the Junk E-mail folder have the expected folder icon instead of the spam icon.

After the tweak has been applied, it works consistently until another Vivaldi update is installed, when this issue recurs. I believe this issue started occurring with the fifth minor update to Vivaldi 5.4, and it recurred with the sixth minor update to 5.4.

I don't know if this is a caching issue, a race condition, if Vivaldi behaves differently on its first launch after an installation, or a defect in VivaldiCustomLauncher that doesn't tweak the file properly on the first run after an installation.

Aldaviva commented 2 years ago

VivaldiCustomLauncher is successfully modifying background-common-bundle.js on its first run. DevTools shows the new file contents when you Inspect the browser (run with --debug-packed-apps) and go into one of the two background service workers, but the old contents are shown when you Inspect Background Service-Worker. This makes me think the file is being cached because it's used by a service worker.

A cached copy can be found in %LOCALAPPDATA%\Vivaldi\User Data\Default\Storage\ext\mpognobbkildjkofajifpdfhcoklimli\def\Service Worker\ScriptCache with a possibly randomly-generated filename (39ae1ddeef4e4d11_0 on one of my computers), although you can identify it by the similar file size of ~856 KB. This cache seems to get invalidated later. I am not sure if there is a way to programmatically invalidate it.

Maybe VivaldiCustomLauncher should delete the entire ScriptCache directory if it performed any changes on any of the files that go into there (background-common-bundle.js and any others that may be added in the future). Or maybe there's a way to make Chromium regenerate its service worker script cache.

The official Vivaldi installer must do something similar to cause updates to these files to take effect. Maybe I could look at what it's doing using Process Monitor during an upgrade and see if it's deleting that directory.

Aldaviva commented 2 years ago

Unfortunately, deleting ScriptCache seems to cause the mail panel and tab to not load until you restart the browser one more time, and the status bar alternates between "Mail client starting..." and "Opening mail DB - This may take time if upgrades are due...".

Aldaviva commented 2 years ago

Fortunately, deleting ScriptCache's parent Service Worker directory from %localappdata%\Vivaldi\User Data\Default\Storage\ext\mpognobbkildjkofajifpdfhcoklimli\def\ both invalidates the cache and does not block the mail panel from loading on the next launch.

Aldaviva commented 2 years ago

Tested the removal of Service Worker in 6605d36 after installing Vivaldi 5.5.2805.32 and it worked successfully. The mail panel loaded, the junk e-mail folder was classified as a normal folder, and I didn't observe any side effects.