Random extreme CPU spikes on random browser tasks

I've noticed that every once in a few days (sometimes daily) my CPU spikes to a 120% or such usage when any of my browsers are open.

The scenario is weird, today I was watching a movie using VLC player and I saw my battery starting to drain unusually fast and my fans running out of control, I open up the Activity Monitor and see that Safari Networking is clogging up my CPU time and usage (100%). My Safari was open but in the background with a few random websites such as Stack Overflow, none Flash-related apps or something along the lines. This was happening on Chrome way too often under the Process Name of Chrome Helper, but with a slightly greater CPU usage.

When I force shutdown the processes either via Activity Monitor or their PID everything returns to normal. Any clues? Happy to post any logs necessary.

macOS High Sierra 10.13, MacBook Pro (13-inch, 2017, Two Thunderbolt 3 ports)


Solution 1:

Here are a few steps you can check:

  1. Do you use Safari extensions? Try uninstalling unused or non-trusted Extensions.
  2. Do you run Java in Safari? Disable the java browser runtime
  3. This sounds too easy, but did you clear Safari Caches and Cookies? Sometimes quitting Safari without restoring windows may help resolve issues.
  4. Go to Safari Preferences and turn off the autoplay video feature for all sites.
  5. If you never clear your Cache the ~/Library/Safari/RecentlyClosedTabs.plist file generates huge file size. Quit Safari and move RecentlyClosedTabs.plist to the trash