Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Redirect Electron/Chromium cache location #30665

Closed
wants to merge 8 commits into from

Conversation

emmkimme
Copy link
Contributor

@emmkimme emmkimme commented Aug 23, 2021

************ DRAFT ***********

Description of Change

This MR fixes or help on the following issues:

Notes: This is a new version of feat: Custom cache path

Checklist

Release Notes

What is managed the cache is a bit complicated to define.

As a matter of rules, what is in the cache is:

  • beyond our control in term of creation / modification and storage format
  • if erased does not prevent the application to start
  • if erased is automatically rebuilt from scratch with 'known' side effects (potentially have to re-enter credentials and re-fill forms, performance of a cold start, ...)

Additional notes

This change is backward compatible.
For concurrent access violation, the cache folder must not be shared by different users.
For performance purpose, it must be set on a fast drive.

@emmkimme emmkimme requested a review from a team as a code owner August 23, 2021 14:33
@electron-cation electron-cation bot added the new-pr 🌱 PR opened in the last 24 hours label Aug 23, 2021
Copy link
Member

@MarshallOfSound MarshallOfSound left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if erased is automatically rebuilt from scratch with 'known' side effects (potentially have to re-enter credentials and re-fill forms, performance of a cold start, ...)

This may be expected for your perspective but for others this is an unacceptable breaking change to Electron that updating will result in cached data ceasing to exist.

This issue hasn't been fixed because no one has implemented a nice way of handling this that doesn't cause data loss.

@anatoli26
Copy link

if erased is automatically rebuilt from scratch with 'known' side effects (potentially have to re-enter credentials and re-fill forms, performance of a cold start, ...)

This may be expected for your perspective but for others this is an unacceptable breaking change to Electron that updating will result in cached data ceasing to exist.

This issue hasn't been fixed because no one has implemented a nice way of handling this that doesn't cause data loss.

It was already discussed at length in #8124, in particular: #8124 (comment).

What is needed in electron is to provide to the electron-based app developers the possibility to define the 3 paths and by default assign them the currently used values, so no functional change results from the code change.

Then each electron-based app dev team decides how to best proceed with the newly available options in their apps.

@emmkimme
Copy link
Contributor Author

Guess, there is some misunderstood, I did not break anything in term of functionality, I just offer a way to redirect the 'cache' to another location, there is no loss of data and the backward compatibility is preserved.
@anatoli26 Thanks for the reference to the discussion, I will have a look.

shell/browser/electron_browser_context.cc Outdated Show resolved Hide resolved
@electron-cation electron-cation bot removed the new-pr 🌱 PR opened in the last 24 hours label Aug 30, 2021
@emmkimme emmkimme changed the title WIP: feat: Redirect Electron/Chromium cache location feat: Redirect Electron/Chromium cache location Aug 30, 2021
@@ -610,6 +610,7 @@ Returns `String` - The current application directory.
* `userData` The directory for storing your app's configuration files, which by
default it is the `appData` directory appended with your app's name.
* `cache`
* `browserData` The directory for storing browsing data.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a note that it defaults to userData?

// update when `name` is changed before `app.ready` is fired. So if app
// isn't ready yet, invalidate the PathService cache to ensure a refresh.
if (!Browser::Get()->is_ready()) {
base::PathService::InvalidateCache();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The cache does not interfere with paths set by app.setPath, it is mostly about the path providers, which we do not expose any JavaScript in Electron, so I think we can remove this InvalidateCache call.

@aairey
Copy link

aairey commented Dec 21, 2021

@emmkimme could you have another look at this, please?

@emmkimme
Copy link
Contributor Author

@emmkimme could you have another look at this, please?

Yes, will manage early next year, have a good end of year.

@reitzig
Copy link

reitzig commented Jan 4, 2022

What is needed in electron is to provide to the electron-based app developers the possibility to define the 3 paths and by default assign them the currently used values, so no functional change results from the code change.

No, we need a "breaking" change! (Quotes because cache location shouldn't matter at all to the app.) A transitionary period would be easy to implement, although more work than just changing the paths to something appropriate.

Then each electron-based app dev team decides how to best proceed with the newly available options in their apps.

So we get a non-standardized mess instead of a bad standard? If they change it at all? No, thanks. Electron needs a fix, not the apps.

@emmkimme
Copy link
Contributor Author

emmkimme commented Jan 10, 2022

What is needed in electron is to provide to the electron-based app developers the possibility to define the 3 paths and by default assign them the currently used values, so no functional change results from the code change.

No, we need a "breaking" change! (Quotes because cache location shouldn't matter at all to the app.) A transitionary period would be easy to implement, although more work than just changing the paths to something appropriate.

Then each electron-based app dev team decides how to best proceed with the newly available options in their apps.

So we get a non-standardized mess instead of a bad standard? If they change it at all? No, thanks. Electron needs a fix, not the apps.

To be fair, we are a bit lost. It seems to have a long discussion/context feed by experts on this area, and clearly, we are not and do not even pretend to be.

We implemented this solution in our own Electron 4 years ago and it resolves the concerns of our customer which are on Citrix, VDI,... (see issues mentioned).

We had the naive feeling it could help other people facing the same problem and as good citizen, we would like to contribute.
This is our 3rd revised MR because code changed so often these past years.

If the general feedback is, this MR does not help at all, it is not even a first step to the right direction, too specific, raise more issues than the ones solved,... so it does not make sense to keep going. We will wait for a better contribution from the Electron community, hope it will
come soon and then be able use an Electron without patching it. Thanks for your comments.

@miniak
Copy link
Contributor

miniak commented Mar 19, 2022

@emmkimme are you still planning to work on this PR?

@emmkimme
Copy link
Contributor Author

The solution works fine on my side for more than 3 years and deployed with our product on hundreds of thousands users (Mac, Linux, Windows) without any issues. It fixes 5 and 7 years old issues which prevents Electron to manage properly Virtual Env.
To be fair, I'm tired to fight for this MR (more than 4 Years !), people always pointed me to a never ending thread #8124 started in 2016, and still nothing !,
In all innocence, I thought this MR was a good first step to a better solution, seems definitely not.
So I give up and I hope, one day, a solution will be finally implemented, for those that are not in position to compile their own versions of Electron.

@zcbenz
Copy link
Member

zcbenz commented Mar 31, 2022

I'm continuing the work of this PR in #33554.

@zcbenz zcbenz closed this Mar 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants