[BUG] 20% CPU overhead in kindness mode
As soon as the kindness mode is on, Orbox starts a process that uses about 20% of the CPU and cannot be turned off. Not even if the mode is turned off. I don't think that's intended. It helps to end the process or the app.
Xiaomi POCO X3 pro
Snowflake Proxy mode may not be getting turned off properly
Profiling memory and CPU usage confirms this:
The spike in CPU usage, is when I turn Kindness mode on. Then I turned it off. Then I took the screenshot. No downward curve to be witnessed.
However, the code looks totally unsuspicious.
I debugged it, #disableSnowflakeProxy seems to be getting called without problem.
public synchronized void disableSnowflakeProxy() {
if (mSnowflakeProxy != null) {
mSnowflakeProxy.stop();
logNotice(getString(R.string.log_notice_snowflake_proxy_disabled));
if (Prefs.showSnowflakeProxyMessage()) {
var message = getString(R.string.log_notice_snowflake_proxy_disabled);
new Handler(getMainLooper()).post(() -> Toast.makeText(getApplicationContext(), message, Toast.LENGTH_LONG).show());
}
mSnowflakeProxy = null;
}
}
Actually a little too often for my tastes... I witnessed WiFi changes which didn't really happen - the device seemed connected continuously, but Snowflake Proxy was turned off and on again.
Anyway, a logic bug in Orbot itself seems out of the question.
But, IPtProxy looks good, too:
// Stop - Stop the Snowflake proxy.
func (sp *SnowflakeProxy) Stop() {
if sp.isRunning {
sp.proxy.Stop()
sp.proxy.EventDispatcher.RemoveSnowflakeEventListener(sp)
sp.isRunning = false
sp.proxy = nil
}
}
And the Snowflake code, just as well:
for ; true; <-ticker.C {
select {
case <-sf.shutdown:
return nil
default:
tokens.get()
sessionID := genSessionID()
sf.runSession(sessionID)
}
}
return nil
}
// Stop closes all existing connections and shuts down the Snowflake.
func (sf *SnowflakeProxy) Stop() {
close(sf.shutdown)
}
So… I'm at a loss, here.
@cohosh, sorry that I have to summon you once again… Do you have any ideas?
How about this: https://github.com/guardianproject/orbot-android/issues/1241
Hmm, I'll poke around a bit. I wonder if there is a race condition with the shutdown channel getting closed, and the proxy also waiting for a new snowflake.
I seem to remember seeing the 20% once when I hadn't turned on the Kindness mode yet. But it usually turns on when the mode is turned on.
@Android-PowerUser what version of orbot are you using?
Version 17.3.2-RC-1-tor-0.4.8.12
Seems to be related to https://github.com/guardianproject/orbot-android/issues/1091.