secureblue / hardened-chromium

A hardened chromium for desktop Linux inspired by Vanadium.
GNU General Public License v2.0
18 stars 5 forks source link

disable various ai features by default #7

Closed qoijjj closed 6 days ago

qoijjj commented 1 month ago

https://source.chromium.org/chromium/chromium/src/+/main:components/compose/core/browser/compose_features.cc;l=13?q=kEnableCompose%20lang:cc&ss=chromium%2Fchromium%2Fsrc

RKNF404 commented 1 month ago

Compose, along with a few other AI features, appear to be opimization guides: https://source.chromium.org/chromium/chromium/src/+/main:components/optimization_guide/core/model_execution/model_execution_prefs.cc;l=19;bpv=0;bpt=1 Not sure if actually disabling opimization guides would or would not cause these features to also be disabled. I'm inclined to believe that is the case based on this function: https://source.chromium.org/chromium/chromium/src/+/main:chrome/browser/optimization_guide/optimization_guide_keyed_service_factory.cc;l=26 It is probably best then to disable OptimizationHints since that is what is used to disable most annoyances related to optimization guides, assuming what I think is true and it doesn't intialize any guide related features when this is disabled.

qoijjj commented 1 month ago

@RKNF404 I think that code is referring to an optimization guide for compose, but I'm not sure. I don't think optimization hints/guides on their own are a bad thing, they improve performance.

https://go.dev/solutions/google/chrome

RKNF404 commented 1 month ago

@qoijjj I don't think so, seems like these features are just defined under the optimization_guide namespace. Since they can be disabled via policy and the policy affects these prefs. They seem to group execution models (or AI features like compose) in with guides and hints. Check this out: https://source.chromium.org/chromium/chromium/src/+/main:chrome/browser/compose/compose_enabling.cc;l=190 If opt_guide == nullptr it will not enable compose, and it gets the value of opt_guide from: https://source.chromium.org/chromium/chromium/src/+/main:chrome/browser/compose/compose_enabling.cc;l=174 Which calls the function I linked above which returns nullptr when optimization guides are disabled. This may be just for compose but I'm pretty all the other AI BS is also disabled with similar logic.

qoijjj commented 1 month ago

@RKNF404 I see, I'll look into this further in a bit. Even if that's the case though, I'm not sure that justifies removing optimizationguides altogether

RKNF404 commented 1 month ago

I guess, doesn't seem that significant in my opinion, especially since disabling it also disables the privacy intrusive AI stuff. Depends on how noticable the performance loss could be if they are disabled?

qoijjj commented 1 month ago

@RKNF404 it depends on the implementation. if it's using pretrained models locally to do performance optimizations, there would be no downside. I'll need to look into this further

qoijjj commented 1 month ago

@RKNF404 I've been looking into this more. It looks like optimization guides are integrated with compose, but compose doesn't depend on them. It's a soft dependency:

https://source.chromium.org/chromium/chromium/src/+/main:chrome/browser/compose/compose_enabling.cc;l=138?q=kEnableCompose%20lang:cc&ss=chromium%2Fchromium%2Fsrc

If there is no optimization guide found, then COMPOSE_HINT_DECISION_UNSPECIFIED is returned, whereas COMPOSE_HINT_DECISION_COMPOSE_DISABLED disables compose.

so these would need to be disabled independently.

qoijjj commented 1 month ago

Please let me know if I'm reading that wrong though

qoijjj commented 1 month ago

this makes sense though because optimization guides are about page load optimizations, whereas compose is a context menu feature to do content generation

RKNF404 commented 1 month ago

@qoijjj looking at it, you're right. It would appear compose isn't exactly disabled when it is unspecified: https://source.chromium.org/chromium/chromium/src/+/main:chrome/browser/compose/compose_enabling.cc;l=297;drc=2017cd8a8925f180257662f78eaf9eb93e8e394d Disabling the feature directly makes more sense.

RKNF404 commented 1 month ago

The more I look into that call/definition chain, the more right you are. Opt guides are integrated but not a dependency of operation, I guess.

qoijjj commented 3 weeks ago

copying some additional options to look at that @RKNF404 mentioned in discord:

"CreateThemesSettings": 2, "DevToolsGenAiSettings": 2, "GoogleSearchSidePanelEnabled": false, "HelpMeWriteSettings": 2, "TabOrganizerSettings": 2,,

qoijjj commented 3 weeks ago

for kGoogleSearchSidePanelEnabled, the policy is set to true by default. However, the functionality doesn't show up for me (when I select text, right click, and search with google, it opens in a new tab).

So I dug a bit more. the policy gets checked here:

https://source.chromium.org/chromium/chromium/src/+/main:chrome/browser/ui/views/side_panel/companion/companion_utils.cc;l=69;bpv=1;bpt=1?q=kGoogleSearchSidePanelEnabled%20lang:cc&ss=chromium%2Fchromium%2Fsrc&start=11

and that function is used here:

https://source.chromium.org/chromium/chromium/src/+/main:chrome/browser/ui/views/side_panel/companion/companion_utils.cc;l=121?q=GoogleSearchSidePanelEnabled%20lang:cc&ss=chromium%2Fchromium%2Fsrc&start=1

but the call to that function isn't reached if the companion feature is disabled:

https://source.chromium.org/chromium/chromium/src/+/main:chrome/browser/ui/views/side_panel/companion/companion_utils.cc;l=93;drc=5203366d4cf174b9331ee33563e0520f10b60828

and the companion feature is disabled when GOOGLE_CHROME_BRANDING is false

So, at least for this policy no action is needed.

qoijjj commented 3 weeks ago

For HelpMeWriteSettings, the policy is mapped to kComposeEnterprisePolicyAllowed:

https://source.chromium.org/chromium/chromium/src/+/main:chrome/browser/policy/configuration_policy_handler_list_factory.cc;l=2214?q=HelpMeWriteSettings%20lang:cc&ss=chromium%2Fchromium%2Fsrc&start=21

which is enabled by default here: https://source.chromium.org/chromium/chromium/src/+/main:components/optimization_guide/core/model_execution/model_execution_prefs.cc;l=40?q=kComposeEnterprisePolicyAllowed%20lang:cc&ss=chromium%2Fchromium%2Fsrc

So I just need to flip that flag

qoijjj commented 3 weeks ago

same for:

{ key::kCreateThemesSettings, optimization_guide::model_execution::prefs::kWallpaperSearchEnterprisePolicyAllowed,

{ key::kTabOrganizerSettings, optimization_guide::model_execution::prefs::kTabOrganizationEnterprisePolicyAllowed, base::Value::Type::INTEGER},

qoijjj commented 3 weeks ago

~for devtools it's set to allowwithoutlogging here:~

~https://source.chromium.org/chromium/chromium/src/+/main:chrome/browser/devtools/aida_client.cc;l=139?q=kDevToolsGenAiSettings%20lang:cc&ss=chromium%2Fchromium%2Fsrc&start=11~

nvm, it's also allowed here: https://source.chromium.org/chromium/chromium/src/+/main:chrome/browser/devtools/devtools_window.cc;l=535?q=DevToolsGenAiEnterprisePolicyValue&ss=chromium%2Fchromium%2Fsrc

qoijjj commented 3 weeks ago

https://github.com/secureblue/hardened-chromium/pull/41

leaving this issue open because there are additional ai features getting added to upstream

RKNF404 commented 6 days ago

@qoijjj this issue can be closed right? Now that the history AI feature has been disabled.