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

High CPU usage when running in background #210

Closed
interpretor opened this issue Jul 23, 2019 · 23 comments
Closed

High CPU usage when running in background #210

interpretor opened this issue Jul 23, 2019 · 23 comments
Assignees
Labels
Bug Something isn't working P3: Medium Medium priority
Milestone

Comments

@interpretor
Copy link

Steps to reproduce

  1. Start Adguard for Safari
  2. Close Window

Expected behavior

Adguard for Safari should not have any noticeable CPU usage when running in background

Actual behavior

Adguard for Safari uses about 3 - 5% on a Quad-Core i7

Your environment

  • AdGuard for Safari version: 1.4.1
  • Environment name and version: Safari 12.1.2 (14607.3.9)
  • Operating System: macOS Mojave 10.14.6
  • Filters you use in AdGuard: Default
  • Any other browser extensions you have installed: -
@ameshkov ameshkov added this to the 1.5 milestone Jul 23, 2019
@ameshkov
Copy link
Member

@Mizzick any idea how we can troubleshoot this?

Obviously, we cannot reproduce this so I guess the only way would be to start writing a log file & introduce logging level

@Mizzick
Copy link
Contributor

Mizzick commented Jul 23, 2019

We actually do write the log file.
This file could be found ~/Library/Logs/<app name>/log.log

@interpretor
Copy link
Author

This problem exists on multiple macOS devices including Macbook Pro and Mac mini, so it should be reproducible on your side.

@ameshkov
Copy link
Member

@interpretor could you please try the standalone build just in case?
https://github.com/AdguardTeam/AdGuardForSafari/releases/tag/v1.4.1

@dropwhile
Copy link

dropwhile commented Jul 29, 2019

Same issue here (cpu usage in background when not fetching/checking updates).

I did a bit of digging with dtruss (sudo dtruss -p <pid-of-adguard-for-safari-process>). If I run dtruss against the cpu using pid in question, I get lots of repeated stat64 calls for files in a subdir named app.asar; files which do not exist -- app.asar appears to be an electron archive type, and the files do exist inside the archive.

Viewing/extracting with npm asar module shows contents, and so it doesn't seem corrupted. Not sure why it isn't working as expected. Maybe an electron bug?

Some sample dtruss output (repeats over and over and over):

expand for output
stat64("/Applications/AdGuard for Safari.app/Contents/Resources/app.asar/src/main/app/utils/log.js\0", 0x70000630CE00, 0x0)		 = -1 Err#20
stat64("/Applications/AdGuard for Safari.app/Contents/Resources/app.asar/src/main/ui/images/triangle.svg\0", 0x700006B0FE00, 0x0)		 = -1 Err#20
stat64("/Applications/AdGuard for Safari.app/Contents/Resources/app.asar/src/main/ui/js/i18n/i18n-helper.js\0", 0x70000630CE00, 0x0)		 = -1 Err#20
stat64("/Applications/AdGuard for Safari.app/Contents/Resources/app.asar/src/utils/i18n.js\0", 0x700006B0FE00, 0x0)		 = -1 Err#20
stat64("/Applications/AdGuard for Safari.app/Contents/Resources/app.asar/src/main/ui/images/tick.svg\0", 0x700006B0FE00, 0x0)		 = -1 Err#20
psynch_mutexdrop(0x11107AC80, 0x47F6F00, 0x47F6F00)		 = 0 0
psynch_cvwait(0x11107ACC0, 0x163200001632400, 0x1632000)		 = 0 0
stat64("/Applications/AdGuard for Safari.app/Contents/Resources/app.asar/README.md\0", 0x700007312E00, 0x0)		 = -1 Err#20
stat64("/Applications/AdGuard for Safari.app/Contents/Resources/app.asar/locales/ja.json\0", 0x700006B0FE00, 0x0)		 = -1 Err#20
kevent(0x8, 0x7FFEE43CA720, 0x0)		 = 1 0
stat64("/Applications/AdGuard for Safari.app/Contents/Resources/app.asar/safari-ext/package.json\0", 0x700007312E00, 0x0)		 = -1 Err#20
dtrace: error on enabled probe ID 2174 (ID 159: syscall::read:return): invalid kernel access in action #12 at DIF offset 68
stat64("/Applications/AdGuard for Safari.app/Contents/Resources/app.asar/safari-ext/build/safari_ext_addon.target.mk\0", 0x700006B0FE00, 0x0)		 = -1 Err#20
dtrace: error on enabled probe ID 2172 (ID 161: syscall::write:return): invalid kernel access in action #12 at DIF offset 68
psynch_mutexdrop(0x11107ADA0, 0x19D4700, 0x19D4700)		 = 0 0
psynch_mutexwait(0x11107ADA0, 0x19D4702, 0x19D4600)		 = 27084547 0
stat64("/Applications/AdGuard for Safari.app/Contents/Resources/app.asar/safari-ext/build/Makefile\0", 0x700005B09E00, 0x0)		 = -1 Err#20
stat64("/Applications/AdGuard for Safari.app/Contents/Resources/app.asar/locales/zh-cn.json\0", 0x700006B0FE00, 0x0)		 = -1 Err#20
stat64("/Applications/AdGuard for Safari.app/Contents/Resources/app.asar/filters/filter_mobile_8.txt\0", 0x700007312E00, 0x0)		 = -1 Err#20
stat64("/Applications/AdGuard for Safari.app/Contents/Resources/app.asar/locales/ru.json\0", 0x700005B09E00, 0x0)		 = -1 Err#20
stat64("/Applications/AdGuard for Safari.app/Contents/Resources/app.asar/src/main/ui/images/logo-shield.svg\0", 0x700006B0FE00, 0x0)		 = -1 Err#20
stat64("/Applications/AdGuard for Safari.app/Contents/Resources/app.asar/src/main/app/storage\0", 0x700005B09E00, 0x0)		 = -1 Err#20
stat64("/Applications/AdGuard for Safari.app/Contents/Resources/app.asar/src/main/ui/js/libs/ace\0", 0x700007312E00, 0x0)		 = -1 Err#20
stat64("/Applications/AdGuard for Safari.app/Contents/Resources/app.asar/src/main/app/storage/rules-storage.js\0", 0x700006B0FE00, 0x0)		 = -1 Err#20
stat64("/Applications/AdGuard for Safari.app/Contents/Resources/app.asar/src/main/updater.js\0", 0x700005B09E00, 0x0)		 = -1 Err#20
stat64("/Applications/AdGuard for Safari.app/Contents/Resources/app.asar/safari-ext/build/Release\0", 0x700007312E00, 0x0)		 = -1 Err#20
stat64("/Applications/AdGuard for Safari.app/Contents/Resources/app.asar/safari-ext/shared/CommonLib/Lang/Logger/Lumberjack/DDLogMacros.h\0", 0x700006B0FE00, 0x0)		 = -1 Err#20
stat64("/Applications/AdGuard for Safari.app/Contents/Resources/app.asar/src/main/app/app.js\0", 0x700005B09E00, 0x0)		 = -1 Err#20
stat64("/Applications/AdGuard for Safari.app/Contents/Resources/app.asar/safari-ext/shared/CommonLib/Lang/NSDate+Utils.h\0", 0x700007312E00, 0x0)		 = -1 Err#20
stat64("/Applications/AdGuard for Safari.app/Contents/Resources/app.asar/src/main/app/filters/filters-update.js\0", 0x700006B0FE00, 0x0)		 = -1 Err#20
stat64("/Applications/AdGuard for Safari.app/Contents/Resources/app.asar/config/default.json\0", 0x700005B09E00, 0x0)		 = -1 Err#20
stat64("/Applications/AdGuard for Safari.app/Contents/Resources/app.asar/src/main/app/utils/i18n.js\0", 0x700007312E00, 0x0)		 = -1 Err#20
stat64("/Applications/AdGuard for Safari.app/Contents/Resources/app.asar/src/main/ui/css/main.css\0", 0x700005B09E00, 0x0)		 = -1 Err#20
stat64("/Applications/AdGuard for Safari.app/Contents/Resources/app.asar/locales/pt-pt.json\0", 0x700006B0FE00, 0x0)		 = -1 Err#20
stat64("/Applications/AdGuard for Safari.app/Contents/Resources/app.asar/safari-ext/yarn.lock\0", 0x700007312E00, 0x0)		 = -1 Err#20
stat64("/Applications/AdGuard for Safari.app/Contents/Resources/app.asar/safari-ext/shared/CommonLib/Lang/Logger/Lumberjack/DDLegacyMacros.h\0", 0x700005B09E00, 0x0)		 = -1 Err#20
stat64("/Applications/AdGuard for Safari.app/Contents/Resources/app.asar/filters/filter_6.txt\0", 0x700006B0FE00, 0x0)		 = -1 Err#20
stat64("/Applications/AdGuard for Safari.app/Contents/Resources/app.asar/src/main/ui/images/checked.svg\0", 0x700007312E00, 0x0)		 = -1 Err#20
stat64("/Applications/AdGuard for Safari.app/Contents/Resources/app.asar/tasks\0", 0x700006B0FE00, 0x0)		 = -1 Err#20
stat64("/Applications/AdGuard for Safari.app/Contents/Resources/app.asar/filters/filter_10.txt\0", 0x700005B09E00, 0x0)		 = -1 Err#20
stat64("/Applications/AdGuard for Safari.app/Contents/Resources/app.asar/filters/filter_2.txt\0", 0x700007312E00, 0x0)		 = -1 Err#20
stat64("/Applications/AdGuard for Safari.app/Contents/Resources/app.asar/safari-ext/shared/CommonLib/Lang/ACLFileLogger.h\0", 0x700006B0FE00, 0x0)		 = -1 Err#20
stat64("/Applications/AdGuard for Safari.app/Contents/Resources/app.asar/src/main/app/filters\0", 0x700005B09E00, 0x0)		 = -1 Err#20
stat64("/Applications/AdGuard for Safari.app/Contents/Resources/app.asar/safari-ext/shared/CommonLib/Lang/Logger/Lumberjack/DDFileLogger.h\0", 0x700007312E00, 0x0)		 = -1 Err#20
stat64("/Applications/AdGuard for Safari.app/Contents/Resources/app.asar/filters/filter_9.txt\0", 0x700005B09E00, 0x0)		 = -1 Err#20
stat64("/Applications/AdGuard for Safari.app/Contents/Resources/app.asar/safari-ext/shared/CommonLib/Lang\0", 0x700006B0FE00, 0x0)		 = -1 Err#20
stat64("/Applications/AdGuard for Safari.app/Contents/Resources/app.asar/safari-ext/shared/CommonLib/Lang/Logger/Lumberjack/DDAbstractDatabaseLogger.h\0", 0x700005B09E00, 0x0)		 = -1 Err#20

@dropwhile
Copy link

dropwhile commented Jul 29, 2019

Also, no adguard logs in ~/Library/Logs. There is a log file in ~/Library/Containers/com.adguard.safari.AdGuard/Data/Library/Logs named log.log, but the contents seem to be only updated when filters are updated, and there appears to be no correlation with the cpu issue in question (eg. last filter update was hours ago, and no log entries in that file since then).

@zzebrum zzebrum added Bug Something isn't working P3: Medium Medium priority labels Jul 30, 2019
@amok-san
Copy link

FWIW the beta from 3 days before doesn't show this behavior.

@ameshkov
Copy link
Member

Well, this must have something to do with the sandbox that is used in the Mac App Store build. Standalone build is different.

@amok-san
Copy link

OK, but what do I have to do to get the final release from github running?

It crashes upon opening and says:
Termination Reason: DYLD, [0x5] Code Signature

@interpretor
Copy link
Author

OK, but what do I have to do to get the final release from github running?

It crashes upon opening and says:
Termination Reason: DYLD, [0x5] Code Signature

I also would be interested in an answer to this question. The final release crashes upon startup.

@Mizzick
Copy link
Contributor

Mizzick commented Aug 19, 2019

@amok-san @interpretor the release is fixed, thanks for your attention

@jwchong
Copy link

jwchong commented Aug 30, 2019

Hi,
Using Max App Store version and background CPU usage problem still there. Any fixes? Thanks.

@ameshkov ameshkov modified the milestones: 1.5, 1.6 Sep 9, 2019
@cpgn
Copy link

cpgn commented Sep 13, 2019

Hi,
AdGuard for Safari version 1.4.1 downloaded via App Store still showing the same behaviour.
Will there be a fix?
Cheers

@ameshkov
Copy link
Member

We don't understand yet why there is such a difference between the AppStore and the standalone build. Once v1.5 is released on AppStore, we'll revisit this issue. Hopefully, it'll happen next week.

@ameshkov
Copy link
Member

Hi everyone, we've just released v1.5 to MAS: https://github.com/AdguardTeam/AdGuardForSafari/releases/tag/v1.5.4

Could you please check if the issue is still present?

@cpgn
Copy link

cpgn commented Sep 20, 2019

It's fixed for me! Well done, guys

@ameshkov ameshkov modified the milestones: 1.6, 1.5 Sep 20, 2019
@ameshkov
Copy link
Member

Awesome, thanks for testing it!

@interpretor
Copy link
Author

While the release is great (added up to 300.000 possible filters), I unfortunately have to tell you, that the problem still exists in the current App Store version of your application. Having about 5-6% CPU usage while doing nothing.
I'll check the github release in a minute.

@ameshkov ameshkov reopened this Sep 20, 2019
@ameshkov ameshkov modified the milestones: 1.5, 1.6 Sep 20, 2019
@ameshkov
Copy link
Member

:(

@ameshkov
Copy link
Member

ameshkov commented Sep 20, 2019

@interpretor I wonder what's the difference between yours and @cpgn configurations.

What MacOS versions do you have?

@interpretor
Copy link
Author

Ignore my previous post. It seems fixed now!
A reboot worked wonders here.

@ameshkov
Copy link
Member

🎉🎉🎉

@interpretor thank you:)

@dropwhile
Copy link

Fixed here also! ❤️

Mizzick added a commit that referenced this issue Oct 10, 2019
…re/233-1 to master

* commit '44822b828867af49e4e7141d701ddf2a48d5cdf7':
  fix rules count
  fix rules count
  #233 performance
  #233 background windows focus
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working P3: Medium Medium priority
Projects
None yet
Development

No branches or pull requests

8 participants