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

Userscripts extension stops working after a while of Safari uptime until Safari is quit and restarted #245

Closed
v7rzlhb3xg opened this issue Apr 30, 2022 · 20 comments

Comments

@v7rzlhb3xg
Copy link

Hey, I think I noticed this begin to happen with the latest macOS update. After a while of having Safari open I'll notice that Userscripts just stops working -- no scripts are being injected and the developer console doesn't show any Userscripts activity either. Clicking on the Userscripts extension icon in my Safari toolbar also just gives me the endless spinning loading circle. The only thing that seems to fix it is restarting Safari again. I've experienced this on both the App Store release version as well as the latest TestFlight beta version. Let me know if there's any more information I can provide.

System Information:

macOS or iOS version: macOS Monterey 12.3.1
Userscripts version: 4/1/7 (47)
Safari version: 15.4
Is this issue related to script injection? Yes

@quoid
Copy link
Owner

quoid commented May 1, 2022

@v7rzlhb3xg

Thanks for reporting this. I have some follow up questions/comments:

noticed this begin to happen with the latest macOS update

Are you referring to the macOS 12.3.1 update? or an update to the userscripts app?

and the developer console doesn't show any Userscripts activity either

There are some other places to look, if you don't mind. I will list them below.

Extension popup

If you right click anywhere in the extension popup, you should get a tooltip that offer the option called Inspect Element. When you select that option a browser tools will open and if you navigate the Console section you will see error that are specific to the extension popup.

Extension popup errors do not get logged in the "normal" browser console.
Screen Shot 2022-04-30 at 8 05 31 PM

Background page

The background page is where a lot of the app logic lives. When errors occur here, they also do not log in the "normal" browser console, but you can view the browser tools for this background page by navigating to the Safari option Developer > Web Extension Background Pages > Userscripts.

You might notice that the background page for this app might be labeled as Userscripts (not loaded) or Userscripts - Background Page. This is because this extension uses a non-persistent background page, or "event-driven" background page. When the background page has not responded to an event in a while, it unloads itself. This is required for iOS and likely will soon be required for macOS. For consistency and code-sharing I use the same background page in both macOS and iOS.

That being said, when you click on the option for Userscripts in that menu, a browser tools should open and you can navigate to the Console section and see any errors that have been logged.

Screen Shot 2022-04-30 at 8 11 53 PM

Console.app

The last place to check for errors is Console.app. There's some directions on how to do that here. However, I believe you would likely see errors using the above 2 methods if you are seeing a spinning loading element but nothing happening in popup.


If I had to guess, I would say that the extension (for some reason) stopped responding to events, which drives the logic throughout the different parts of the app. As mentioned above, this extension is event-driven and the background and popup page simply listen for various events and respond accordingly.

At one point I did encounter an issue while working locally where the extension stopped responding to events, for no discernible reason. From what I saw, it simply stopped responding to events. Unfortunately I could not reproduce the issue and it spontaneously stopped presenting itself; I can not recall if that was before or after the most recent macOS update.

My gut tells me this could be an upstream issue with Safari, since the event logic is fairly standard.

If you encounter this again and are up to doing some bug checking using the methods above I would really appreciate it. Also, if you figure out a way to reliably reproduce the issue please let me know.

@v7rzlhb3xg
Copy link
Author

@quoid

Are you referring to the macOS 12.3.1 update? or an update to the userscripts app?

Sorry, that wasn't clear -- I'm referring to the latest macOS 12.3.1 update, that seems to coincide with when I started noticing this issue with Userscripts.

Unfortunately, nothing seems to be coming up in the developer console in either of the first two methods you listed. Opening the Console.app and filtering for any Userscripts related logs does have some results though, here are some screenshots of that. Not entirely sure what's normal and what isn't so I've included everything I could find! Can't seem to figure out a way to reproduce it reliably other than just having Safari open for half a day or so. I'll mess around with the scripts I have installed to see if it's a certain one potentially acting up.

Screen Shot 2022-05-01 at 1 00 09 PM

Screen Shot 2022-05-01 at 12 59 49 PM

Screen Shot 2022-05-01 at 12 59 52 PM

Screen Shot 2022-05-01 at 12 59 55 PM

@quoid
Copy link
Owner

quoid commented May 1, 2022

@v7rzlhb3xg thank you for looking into this

Unfortunately, nothing seems to be coming up in the developer console in either of the first two methods you listed.

I am surprised nothing was logged there. That makes me think what you are experiencing is different than what I experienced and that my theory as to what was going on is incorrect.

Opening the Console.app and filtering for any Userscripts related logs does have some results though

Most of those are spurious "errors". They've existed since the inception of the extension and Apple has said they can safely be ignored. However that first error, about the CPU usage, I have never seen before. When looking at my own console, I do see similar message for other apps (image below).

I'm not sure if that's indicating an issue, but seeing that 100% cpu is being used by the extension for that long doesn't feel right, even if it is not the cause of the issue at hand.

Can't seem to figure out a way to reproduce it reliably other than just having Safari open for half a day or so.

When you have Safari open, does your macbook remain open as well or are you closing the lid/sleeping the machine and just continuing your session?

For me, I tend to keep quite long safari sessions, but I do sleep the my macbook when not being used (by closing the lid). I am curious if there's a way I could try to repro the bug on my machine as well.

Also, if you don't mind, could you share what hardware macbook version youre using?


Screen Shot 2022-05-01 at 1 42 23 PM

@zexpe
Copy link

zexpe commented May 21, 2022

I have the same problem where I open my MacBook Pro (M1 Pro 2021) and notice that the Userscripts extension is using 100% CPU, as if it were stuck in an infinite loop. Disabling and re-enabling the extension gets it working fine again, but it regularly returns to this state after the laptop is closed and opened again. I also first noticed this about a month ago, so it may be macOS 12.3.1 related.

@v7rzlhb3xg
Copy link
Author

The issue I was having has seemingly resolved itself between upgrading to macOS Monterey 12.4, doing a full clean and fresh reinstall of Userscripts from the App Store, and then reinstalling the beta version. Not sure what exactly fixed it!

@quoid
Copy link
Owner

quoid commented May 21, 2022

@zexpe

...and notice that the Userscripts extension is using 100% CPU...

Is it possible for you to provide a screenshot of the console and any diagnostic or bug reports from console.app that mention Userscripts?

I am not sure what this could be, whether or not there is an issue with our code or something with macos or safari.

@zexpe
Copy link

zexpe commented May 21, 2022

Ah, I was going to check if 12.4 was out, but I forgot... I will install that and see if the issue goes away.

@quoid here's a paste of the console log:

Date/Time: 2022-05-21 15:46:14.669 +0100
End time: 2022-05-21 15:48:38.991 +0100
OS Version: macOS 12.3.1 (Build 21E258)
Architecture: arm64e
Report Version: 35
Incident Identifier: 95E8A289-7565-4E55-AE27-20218F3FE617
Share With Devs: Yes

Data Source: Microstackshots
Shared Cache: 1DF3DFC1-141A-35D0-A4E5-F1E113894C6E slid base address 0x1a88a8000, slide 0x288a8000

Command: Userscripts Extension
Path: /Applications/Userscripts.app/Contents/PlugIns/Userscripts Extension.appex/Contents/MacOS/Userscripts Extension
Identifier: com.userscripts.macos.Userscripts-Extension
Version: 4.1.0 (47)
Team ID: J74Q8V8V8N
Architecture: arm64
Parent: UNKNOWN [1]
PID: 43516

Event: cpu usage
Action taken: none
CPU: 144 seconds cpu time over 144 seconds (100% cpu average), exceeding limit of 80% cpu over 180 seconds
CPU limit: 144s
Limit duration: 180s
CPU used: 144s
CPU duration: 144s
Duration: 144.32s
Duration Sampled: 143.30s
Steps: 73

Hardware model: MacBookPro18,1
Active cpus: 10
HW page size: 16384
VM page size: 16384

Fan speed: 0 rpm
Advisory levels: Battery -> 3, User -> 2, ThermalPressure -> 0, Combined -> 2
Free disk space: 367.43 GB/460.43 GB, low space threshold 3072 MB

Heaviest stack for the target process:
73 start + 516 (dyld + 20616) [0x100dcd088]
73 NSExtensionMain + 240 (Foundation + 1010000) [0x1a9c0b950]
73 EXExtensionMain + 300 (ExtensionFoundation + 134848) [0x1bb6d8ec0]
73 ??? (PlugInKit + 120532) [0x1b42976d4]
73 ??? (PlugInKit + 118512) [0x1b4296ef0]
73 ??? (PlugInKit + 119500) [0x1b42972cc]
73 -[NSXPCListener resume] + 344 (Foundation + 549388) [0x1a9b9b20c]
73 xpc_main + 108 (libxpc.dylib + 98768) [0x1a89131d0]
73 _xpc_objc_main + 876 (libxpc.dylib + 100532) [0x1a89138b4]
73 -[NSRunLoop(NSRunLoop) run] + 92 (Foundation + 1000964) [0x1a9c09604]
73 -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 236 (Foundation + 410128) [0x1a9b79210]
73 CFRunLoopRunSpecific + 600 (CoreFoundation + 533648) [0x1a8c9c490]
73 __CFRunLoopRun + 2532 (CoreFoundation + 538132) [0x1a8c9d614]
73 CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE + 16 (CoreFoundation + 812004) [0x1a8ce03e4]
73 _dispatch_main_queue_callback_4CF + 44 (libdispatch.dylib + 74524) [0x1a8a1c31c]
73 _dispatch_main_queue_drain + 928 (libdispatch.dylib + 75468) [0x1a8a1c6cc]
73 _dispatch_client_callout + 20 (libdispatch.dylib + 16840) [0x1a8a0e1c8]
73 _dispatch_call_block_and_release + 32 (libdispatch.dylib + 9732) [0x1a8a0c604]
73 __112-[EXConcreteExtensionContextVendor _beginRequestWithExtensionItems:listenerEndpoint:withContextUUID:completion:]_block_invoke + 1092 (ExtensionFoundation + 140920) [0x1bb6da678]
73 -[EXExtensionContextImplementation _willPerformHostCallback:] + 84 (ExtensionFoundation + 73372) [0x1bb6c9e9c]
73 __112-[EXConcreteExtensionContextVendor _beginRequestWithExtensionItems:listenerEndpoint:withContextUUID:completion:]_block_invoke.199 + 228 (ExtensionFoundation + 141888) [0x1bb6daa40]
73 ??? (Userscripts Extension + 20736) [0x100c45100]
73 ??? (Userscripts Extension + 26896) [0x100c46910]
73 ??? (Userscripts Extension + 46292) [0x100c4b4d4]
73 ??? (Userscripts Extension + 146412) [0x100c63bec]
73 ??? (Userscripts Extension + 142224) [0x100c62b90]
73 -[NSRegularExpression(NSMatching) firstMatchInString:options:range:] + 188 (Foundation + 775596) [0x1a9bd25ac]
73 -[NSRegularExpression(NSMatching) enumerateMatchesInString:options:range:usingBlock:] + 620 (Foundation + 388468) [0x1a9b73d74]
73 icu::RegexMatcher::find(UErrorCode&) + 1664 (libicucore.A.dylib + 1915168) [0x1ab21d920]
10 icu::RegexMatcher::MatchAt(long long, signed char, UErrorCode&) + 9696 (libicucore.A.dylib + 1927628) [0x1ab2209cc]

Powerstats for: Userscripts Extension [43516] [unique pid 541066]
UUID: 9CB60DBB-6C48-378F-B79B-FEB4D68D79E5
Path: /Applications/Userscripts.app/Contents/PlugIns/Userscripts Extension.appex/Contents/MacOS/Userscripts Extension
Identifier: com.userscripts.macos.Userscripts-Extension
Version: 4.1.0 (47)
Team ID: J74Q8V8V8N
Architecture: arm64
Parent: UNKNOWN [1]
UID: 501
Sudden Term: Tracked (allows idle exit)
Footprint: 5440 KB -> 5856 KB (+416 KB)
Start time: 2022-05-21 15:46:15.363 +0100
End time: 2022-05-21 15:48:38.666 +0100
Num samples: 73 (100%)
Primary state: 73 samples Non-Frontmost App, Non-Suppressed, User mode, Effective Thread QoS Default, Requested Thread QoS Default, Override Thread QoS Unspecified
User Activity: 0 samples Idle, 73 samples Active
Power Source: 3 samples on Battery, 70 samples on AC
73 start + 516 (dyld + 20616) [0x100dcd088]
73 NSExtensionMain + 240 (Foundation + 1010000) [0x1a9c0b950]
73 EXExtensionMain + 300 (ExtensionFoundation + 134848) [0x1bb6d8ec0]
73 ??? (PlugInKit + 120532) [0x1b42976d4]
73 ??? (PlugInKit + 118512) [0x1b4296ef0]
73 ??? (PlugInKit + 119500) [0x1b42972cc]
73 -[NSXPCListener resume] + 344 (Foundation + 549388) [0x1a9b9b20c]
73 xpc_main + 108 (libxpc.dylib + 98768) [0x1a89131d0]
73 _xpc_objc_main + 876 (libxpc.dylib + 100532) [0x1a89138b4]
73 -[NSRunLoop(NSRunLoop) run] + 92 (Foundation + 1000964) [0x1a9c09604]
73 -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 236 (Foundation + 410128) [0x1a9b79210]
73 CFRunLoopRunSpecific + 600 (CoreFoundation + 533648) [0x1a8c9c490]
73 __CFRunLoopRun + 2532 (CoreFoundation + 538132) [0x1a8c9d614]
73 CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE + 16 (CoreFoundation + 812004) [0x1a8ce03e4]
73 _dispatch_main_queue_callback_4CF + 44 (libdispatch.dylib + 74524) [0x1a8a1c31c]
73 _dispatch_main_queue_drain + 928 (libdispatch.dylib + 75468) [0x1a8a1c6cc]
73 _dispatch_client_callout + 20 (libdispatch.dylib + 16840) [0x1a8a0e1c8]
73 _dispatch_call_block_and_release + 32 (libdispatch.dylib + 9732) [0x1a8a0c604]
73 __112-[EXConcreteExtensionContextVendor _beginRequestWithExtensionItems:listenerEndpoint:withContextUUID:completion:]_block_invoke + 1092 (ExtensionFoundation + 140920) [0x1bb6da678]
73 -[EXExtensionContextImplementation _willPerformHostCallback:] + 84 (ExtensionFoundation + 73372) [0x1bb6c9e9c]
73 __112-[EXConcreteExtensionContextVendor _beginRequestWithExtensionItems:listenerEndpoint:withContextUUID:completion:]_block_invoke.199 + 228 (ExtensionFoundation + 141888) [0x1bb6daa40]
73 ??? (Userscripts Extension + 20736) [0x100c45100]
73 ??? (Userscripts Extension + 26896) [0x100c46910]
73 ??? (Userscripts Extension + 46292) [0x100c4b4d4]
73 ??? (Userscripts Extension + 146412) [0x100c63bec]
73 ??? (Userscripts Extension + 142224) [0x100c62b90]
73 -[NSRegularExpression(NSMatching) firstMatchInString:options:range:] + 188 (Foundation + 775596) [0x1a9bd25ac]
73 -[NSRegularExpression(NSMatching) enumerateMatchesInString:options:range:usingBlock:] + 620 (Foundation + 388468) [0x1a9b73d74]
73 icu::RegexMatcher::find(UErrorCode&) + 1664 (libicucore.A.dylib + 1915168) [0x1ab21d920]
10 icu::RegexMatcher::MatchAt(long long, signed char, UErrorCode&) + 9696 (libicucore.A.dylib + 1927628) [0x1ab2209cc]
7 icu::RegexMatcher::MatchAt(long long, signed char, UErrorCode&) + 248 (libicucore.A.dylib + 1918180) [0x1ab21e4e4]
6 icu::RegexMatcher::MatchAt(long long, signed char, UErrorCode&) + 8532 (libicucore.A.dylib + 1926464) [0x1ab220540]
6 icu::RegexMatcher::MatchAt(long long, signed char, UErrorCode&) + 340 (libicucore.A.dylib + 1918272) [0x1ab21e540]
6 icu::RegexMatcher::MatchAt(long long, signed char, UErrorCode&) + 292 (libicucore.A.dylib + 1918224) [0x1ab21e510]
5 icu::RegexMatcher::MatchAt(long long, signed char, UErrorCode&) + 9516 (libicucore.A.dylib + 1927448) [0x1ab220918]
3 icu::RegexMatcher::MatchAt(long long, signed char, UErrorCode&) + 684 (libicucore.A.dylib + 1918616) [0x1ab21e698]
3 icu::RegexMatcher::MatchAt(long long, signed char, UErrorCode&) + 480 (libicucore.A.dylib + 1918412) [0x1ab21e5cc]
2 icu::RegexMatcher::MatchAt(long long, signed char, UErrorCode&) + 8496 (libicucore.A.dylib + 1926428) [0x1ab22051c]
2 icu::RegexMatcher::MatchAt(long long, signed char, UErrorCode&) + 7488 (libicucore.A.dylib + 1925420) [0x1ab22012c]
2 icu::RegexMatcher::MatchAt(long long, signed char, UErrorCode&) + 5256 (libicucore.A.dylib + 1923188) [0x1ab21f874]
2 icu::RegexMatcher::MatchAt(long long, signed char, UErrorCode&) + 3460 (libicucore.A.dylib + 1921392) [0x1ab21f170]
2 icu::RegexMatcher::MatchAt(long long, signed char, UErrorCode&) + 504 (libicucore.A.dylib + 1918436) [0x1ab21e5e4]
2 icu::RegexMatcher::MatchAt(long long, signed char, UErrorCode&) + 272 (libicucore.A.dylib + 1918204) [0x1ab21e4fc]
2 icu::RegexMatcher::MatchAt(long long, signed char, UErrorCode&) + 236 (libicucore.A.dylib + 1918168) [0x1ab21e4d8]
1 icu::RegexMatcher::MatchAt(long long, signed char, UErrorCode&) + 11072 (libicucore.A.dylib + 1929004) [0x1ab220f2c]
1 icu::RegexMatcher::MatchAt(long long, signed char, UErrorCode&) + 10520 (libicucore.A.dylib + 1928452) [0x1ab220d04]
1 icu::RegexMatcher::MatchAt(long long, signed char, UErrorCode&) + 9544 (libicucore.A.dylib + 1927476) [0x1ab220934]
1 icu::RegexMatcher::MatchAt(long long, signed char, UErrorCode&) + 9460 (libicucore.A.dylib + 1927392) [0x1ab2208e0]
1 icu::RegexMatcher::MatchAt(long long, signed char, UErrorCode&) + 8796 (libicucore.A.dylib + 1926728) [0x1ab220648]
1 icu::RegexMatcher::MatchAt(long long, signed char, UErrorCode&) + 8760 (libicucore.A.dylib + 1926692) [0x1ab220624]
1 icu::RegexMatcher::MatchAt(long long, signed char, UErrorCode&) + 8180 (libicucore.A.dylib + 1926112) [0x1ab2203e0]
1 icu::RegexMatcher::MatchAt(long long, signed char, UErrorCode&) + 4600 (libicucore.A.dylib + 1922532) [0x1ab21f5e4]
1 icu::RegexMatcher::MatchAt(long long, signed char, UErrorCode&) + 4552 (libicucore.A.dylib + 1922484) [0x1ab21f5b4]
1 icu::RegexMatcher::MatchAt(long long, signed char, UErrorCode&) + 4476 (libicucore.A.dylib + 1922408) [0x1ab21f568]
1 icu::RegexMatcher::MatchAt(long long, signed char, UErrorCode&) + 828 (libicucore.A.dylib + 1918760) [0x1ab21e728]
1 icu::RegexMatcher::MatchAt(long long, signed char, UErrorCode&) + 500 (libicucore.A.dylib + 1918432) [0x1ab21e5e0]
1 icu::RegexMatcher::MatchAt(long long, signed char, UErrorCode&) + 384 (libicucore.A.dylib + 1918316) [0x1ab21e56c]

Binary Images:
0x100c40000 - 0x100c77fff com.userscripts.macos.Userscripts-Extension 4.1.0 (47) <9CB60DBB-6C48-378F-B79B-FEB4D68D79E5> /Applications/Userscripts.app/Contents/PlugIns/Userscripts Extension.appex/Contents/MacOS/Userscripts Extension
0x100dc8000 - 0x100e43fff dyld (955) /usr/lib/dyld
0x1a88fb000 - 0x1a893cfff libxpc.dylib (2236.100.61) <4C6EB90B-BD32-3CAD-9F25-C9F234775EFB> /usr/lib/system/libxpc.dylib
0x1a8a0a000 - 0x1a8a50fff libdispatch.dylib (1325.100.36) /usr/lib/system/libdispatch.dylib
0x1a8c1a000 - 0x1a915ffff com.apple.CoreFoundation 6.9 (1858.112) <8E1809FF-F5B1-3D9E-BE15-F2E7B1D8CE51> /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation
0x1a9b15000 - 0x1a9f05fff com.apple.Foundation 6.9 (1858.112) <886A3487-88A6-30BB-B179-1A92996C67CF> /System/Library/Frameworks/Foundation.framework/Versions/C/Foundation
0x1ab04a000 - 0x1ab2fffff libicucore.A.dylib (70104) /usr/lib/libicucore.A.dylib
0x1b427a000 - 0x1b42b1fff com.apple.pluginkit.framework 1.0 (1) <85C81A87-A22D-383D-9A5E-C26B0D8A445B> /System/Library/PrivateFrameworks/PlugInKit.framework/Versions/A/PlugInKit
0x1bb6b8000 - 0x1bb703fff com.apple.ExtensionFoundation 34.5 (34.5) /System/Library/PrivateFrameworks/ExtensionFoundation.framework/Versions/A/ExtensionFoundation

@zexpe
Copy link

zexpe commented May 21, 2022

I hadn't realised macOS generates diagnostic reports for high CPU usage processes. Why has nobody ever written an app to notifier the user whenever such a report is created? Would save my battery on a few occasions - I keep the activity monitor CPU usage in the dock, but don't always spot these runaway processes.

Anyway, looking further through the logs I see reports from 28th April (14:13), 12th May (11:25), 19th May (11:45), 21st May (15:48). That's probably a reasonable representation of when it began, and how often it occurs.

@quoid
Copy link
Owner

quoid commented May 21, 2022

Thank you very much @zexpe

It looks like you're on version 4.1.0 (app store version) and not beta, can you confirm for how long you've been using this extension? The reason I ask is that the reports started 28 of April and I am curious if this coincided with a macOS update to (to 12.3 or 12.3.1) or this has been happening since you've been using the extension.

I hadn't realised macOS generates diagnostic reports for high CPU usage processes.

I was also unaware of that until this issue. I am not sure how long they persist for as some that I saw and put in the screenshots above have seemingly disappeared :/ If they are auto-purged then I reckon it's possible there were previous reports before the 28th of April on your machine.

@quoid
Copy link
Owner

quoid commented May 21, 2022

Also would you be willing to send me one of the diagnostic reports? (right click Reveal in Finder in Console.app). My email is on my profile page. If you're not comfortable sending it, I understand, so no pressure.

@zexpe
Copy link

zexpe commented May 21, 2022

I've been using the extension since I got this laptop late last year, and 28th April was when I first saw this problem. So presumably sometime after the update to 12.3.1. My reports go back to 30th March, but I doubt the problem occurred before 28th April - I would have noticed it from the CPU usage in the Activity Monitor app dock icon.

BTW, I've turned on a "Folder Action" to monitor new reports being added to the /Library/Logs/DiagnosticReports folder. It seems to work quite well. UserScripts hit 100% CPU again this evening whilst I was using a different app to Safari on my laptop, without any sleep/wake cycles. I'll e-mail the report to you. Haven't updated macOS yet...

@zexpe
Copy link

zexpe commented Jun 1, 2022

Just happened again on macOS 12.4 now.

Date/Time: 2022-06-01 12:50:18.897 +0100
End time: 2022-06-01 12:52:43.200 +0100
OS Version: macOS 12.4 (Build 21F79)
Architecture: arm64e
Report Version: 35.1
Incident Identifier: 9B448353-F489-4012-BF5D-9029FD7E4757
Share With Devs: Yes

Command: Userscripts Extension
Path: /Applications/Userscripts.app/Contents/PlugIns/Userscripts Extension.appex/Contents/MacOS/Userscripts Extension
Identifier: com.userscripts.macos.Userscripts-Extension
Version: 4.1.0 (47)

Event: cpu usage
Action taken: none
CPU: 144 seconds cpu time over 144 seconds (100% cpu average), exceeding limit of 80% cpu over 180 seconds

@quoid
Copy link
Owner

quoid commented Jun 1, 2022

@zexpe

I haven't yet updated to 12.4, but I am using that folder action you made as well. I haven't yet gotten alerted about Userscripts, but I have for other apps (although their average so far is ~70%).

I was thinking maybe this could be due to hardware limitations, such as older machines, but we have the same model (2021 M1 Pro).

@zexpe
Copy link

zexpe commented Jun 10, 2022

For what it's worth, I've not seen a recurrence of this issue since updating to Userscripts 4.2.0. It's been over a week now without this happening.

@quoid
Copy link
Owner

quoid commented Jun 10, 2022

@zexpe thanks for the update, I have not seen it since setting up the alerts, but I have been on the beta 4.2.0 before I set that up

I'll close this issue, but if it re-appears, feel free to re-open, thanks again

@v7rzlhb3xg
Copy link
Author

Same or at least similar issue has started happening again for me for the past couple weeks. macOS Ventura 13.3.1, Safari 16.4, Userscripts 4.4.1. Scripts seem to stop working after an extended period of Safari uptime, requiring me to either restart Safari or manually load the extension through Menubar > Develop > Web Extension Background Content > Userscripts (not loaded). Can't seem to find any error logs since the extension doesn't load in the first place.

@quoid
Copy link
Owner

quoid commented May 8, 2023

Thanks for the report @v7rzlhb3xg. I am not sure what we can do here without logs 🤔

I just recently upgraded to 13.3.1, so I will personally see if I become affected by this.

@v7rzlhb3xg
Copy link
Author

@quoid Here's two logs I managed to get when Safari crashed after attempting to manually load the extension through the Web Extension Background Content menu, not sure how useful they are but hope they offer some insight!

Safari Crash Report 2023-05-11 21.38.58.txt
Safari Log Report 2023-05-11 21.38.58.txt

@quoid
Copy link
Owner

quoid commented May 12, 2023

Thanks for the logs @v7rzlhb3xg. I didn't see anything glaring in there that would indicate an issue, but then again, I am not great at parsing logs from macOS.

Would you mind backing up all of your scripts and taking note of your settings and trashing the extension folders in ~/Library/Containers? They'd be called Userscripts or com.userscripts.macos - basically any folder that has the word userscripts in it that isn't part of another app.

I am not sure if this would help, but that's something I would try. Again, only if your comfortable doing this and make sure to backup your script files.

@ACTCD
Copy link
Collaborator

ACTCD commented May 12, 2023

@v7rzlhb3xg Hi, when you see "Userscripts (not loaded)", it's normal, background script are automatically unloaded after some time of inactivity, this is how non-persistent background works. Normally, when you open the popup or visit a page matching user scripts, it will be automatically reloaded. So what I want to tell you is that it doesn't mean that the whole extension doesn't work.

If you are able to open the popup interface, you have the opportunity to check the error log in the console of safari devtools, and the same goes for extension page or content scripts. If you find logs showing that the extension's native layer is not responding, you'll be able to find some useful logs in your system's Console.app.

I don't think this extension is causing your safari to crash, if your safari crashes and quits automatically, i think it's probably something else. Anyway, try to follow the instructions above to get a valid log, that will help everyone understand where the issues are.

@quoid , using an absolute path is probably the more accurate way. Press Shift-Command-G (⇧ ⌘ G) in Finder (to open Go to Folder window), paste the following path and press Enter. After Userscripts v4.4.0, they should appear as unambiguous names in Finder.

### Userscripts-Mac-App
~/Library/Containers/com.userscripts.macos/

### Userscripts-Mac-Safari-Extension
~/Library/Containers/com.userscripts.macos.Userscripts-Extension/

### App and Extension Group Container (Shared)
~/Library/Group Containers/J74Q8V8V8N.com.userscripts.macos/

If you haven't changed the save location in the app, here is the default save path for your user scripts:

~/Library/Containers/com.userscripts.macos.Userscripts-Extension/Data/Documents/scripts/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants