-
Notifications
You must be signed in to change notification settings - Fork 190
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
Investigate extension energy consumption anomalies #557
Comments
Hello, this user is me. Thank you for paying attention to this issue. (In addition, I noticed that Userscripts also triggers 20-40% resource consumption when opening a Web page that doesn't require calling scripts. I don't know if this is a normal expectation.) |
It looks like the script has a fairly large header, but I'm still not sure exactly what's causing the problem and will require further in-depth investigation and debugging. But to answer your second question first, due to the way the extension works, on every page load it injects the content script and checks if there is any user script that needs to be injected, so it still requires some resources. But I'm not sure what you mean by "20-40% resource"? |
Maybe my expression is wrong. It’s the “Impact on energy consumption” value in Activity Monitor. I don’t know which unit should be used to express it. |
@CometYZ OK, I see, thanks for the clarification. |
@CometYZ Hello, I have used the script you provided for repeated local testing, but the abnormal energy consumption still cannot be reproduced. After installing the script, the energy consumption value increased, but still could not exceed 20. More specifically, while repeatedly switching the focus between Safari and the activity monitor, this action reflecting an energy consumption value of the extension just around 10-20. But Safari itself has an energy consumption value of about 200-300 (even if I completely disable the extension), which is comparable to the Activity Monitor itself. However, I can observe higher values when scrolling this script up and down in the editor of the extension page, with peaks that can exceed 1000. (But I don't think that's the scene you're talking about.) For reference, can you provide a screen recording showing your observation process? It would be best to include changes in the overall energy consumption of the Extension, Safari, and Activity Monitor itself. |
https://drive.google.com/file/d/1mQ6jYM07bw6YQGIuX9YmYUbHUCe4ZHDw/view?usp=share_link |
@CometYZ Thank you for the information. Now I know, I was observing the wrong process. And yes, I can reproduce the same or even higher values than you. I believe this is the correct rendering. Based on my previous brief speculation, due to the large size of the script (head and body), it would take proportionately more resources to parse it each time. Compared with instantaneous energy impact value, I believe that All things considered, there's probably no easy way around this without breaking existing functionality and experience. To completely solve this problem, overall process optimization is required to reduce the calculations required in each process. This means a lot of refactoring work, some of which we are also working on. However, thank you for your feedback on this issue, which will serve as one of the important reference standards for our subsequent reconstruction work. |
Got it. Thank you for the answer! |
I think I've come up with a way to quickly ease the calculations by checking when the file was last updated, rather than parsing its contents each time. But this means some structural changes and relies on another issue that needs improvement. Just recording this idea, I will try and reconstruct it in the near future. |
There is a review in the App Store:
The user reported that in v4.4.4, possibly after the improvement of #525, they found that the energy consumption was abnormal when switching to Safari, and the energy consumption value in the activity monitor reached 600.
Initial local testing, however, was unable to reproduce the problem, and even with multiple tests containing nearly 20 scripts, the energy consumption value topped out at just around 10. In all other operations, the peak energy consumption hardly exceeds 200.
Since the user does not provide specific usage scenarios, and contextual information such as script type and number, it is not possible to target debugging and reproduce the problem. However, this issue is recorded here if we have the opportunity to be able to get more information or to keep an eye on and investigate the issue, as well as look for ways and spaces for improvement.
The text was updated successfully, but these errors were encountered: