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

(macOS) iCloud save location regularly reset, now impossible to change #728

Closed
thegcat opened this issue Sep 26, 2024 · 40 comments
Closed
Labels
need reproduce Need reproduce or more information

Comments

@thegcat
Copy link

thegcat commented Sep 26, 2024

I tried using Userscripts with an iCloud Drive custom Save Location. I used the com~apple~CloudDocs/UserScripts folder. This works well on iOS, unfortunately there are problems on macOS.

On macOS the extension regularly changed the Save Location back to the default folder. I also tried using the TestFlight version (currently 5.0.0 (108) installed) but the Save Location was also reverted to the default there.

Now I also have the problem that the Save Location is stuck on the default folder. Trying to change the Save Location in the macOS app or in the Safari extension does not work (I tried with Safari open and the app closed, app open and Safari closed, both open, nothing works).

Is this a supported setup? Is there anything I can do to help debug this? Or should I just host my scripts in a git repo and use the built-in update function and not use iCloud anymore?

@ACTCD
Copy link
Collaborator

ACTCD commented Sep 26, 2024

This is very strange. First time I've seen feedback like this.

The two possibilities I can think of immediately are:

  • The application's preferences (plist) are corrupted
  • Your iCloud folder has been recreated
    • If you delete and re-create the folder in the same non-default path, the App will not be able to read or write the new folder (even same path).

Trying to change the Save Location in the macOS app or in the Safari extension does not work

What is the specific performance? Could you screenrecord your operation?

Is this a supported setup? Is there anything I can do to help debug this?

Of course, it's supported. You can get some logs via:

macos_toggle

@ACTCD
Copy link
Collaborator

ACTCD commented Sep 26, 2024

Just to make sure, are you running macOS 15?

I discovered that there are several issues that can be caused by changes related to sandbox permissions in macOS 15.

Have you denied or allowed any system authorization pop-ups regarding the App?

@ACTCD ACTCD added the need reproduce Need reproduce or more information label Sep 27, 2024
@thegcat
Copy link
Author

thegcat commented Sep 27, 2024

Just to make sure, are you running macOS 15?

I discovered that there are several issues that can be caused by changes related to sandbox permissions in macOS 15.

Yes, I use macOS Sequoia 15.0, I think this happened before the update already though.

Have you denied or allowed any system authorization pop-ups regarding the App?

Not that I know of, where would I need to check?

@thegcat
Copy link
Author

thegcat commented Sep 27, 2024

This is very strange. First time I've seen feedback like this.

The two possibilities I can think of immediately are:

  • The application's preferences (plist) are corrupted

  • Your iCloud folder has been recreated

    • If you delete and re-create the folder in the same non-default path, the App will not be able to read or write the new folder (even same path).

The scripts are in an iCloud folder that is marked as "keep contents downloaded". I have no idea what iCloud does with the folder in the background.

Trying to change the Save Location in the macOS app or in the Safari extension does not work

What is the specific performance? Could you screenrecord your operation?

This did work now, so I can't currently reproduce this.

Is this a supported setup? Is there anything I can do to help debug this?

Of course, it's supported. You can get some logs via:

I was under the impression iCloud did things that made using it as Storage for Userscripts difficult :-)

@ACTCD
Copy link
Collaborator

ACTCD commented Sep 27, 2024

Not that I know of, where would I need to check?

Some authorization pop-ups are temporary or one-time, so you can't check them.

The scripts are in an iCloud folder that is marked as "keep contents downloaded". I have no idea what iCloud does with the folder in the background.
I was under the impression iCloud did things that made using it as Storage for Userscripts difficult :-)

As for the "keep downloaded" folder, in theory it shouldn't have too many surprises, but who knows?

Like I said in the issue below, since I don't use iCloud Drive myself, debugging related issues is difficult for me.

And it’s definitely not a priority for me right now.

I believe this issue may occur in macOS 15 or earlier, for example if an "eviction" occurs there.

I also believe that the new "keep downloaded" features of macOS 15 / iOS 18 will play some role.


But if you can reproduce the "cannot change save location" issue, I will check and try to solve it.

But are you sure this issue ever happened in macOS 14 or earlier?

@Morac2
Copy link

Morac2 commented Sep 29, 2024

I'm seeing the same problem after upgrading to MacOS 15.0. I keep the user script folder in iCloud and periodically UserScripts changes it back to the default Container folder. I am able to change it back to the iCloud Folder, so I can fix this, but it does get annoying.

This was never an issue on prior versions of MacOS.

I have seen the same thing happen with my iPhone and iPad on iOS 18. I have the scripts folder set to keep downloaded.

Of note, there is no issue with the actual files syncing in iCloud, it's just that the UserScript extension periodically changes the user set folder back to the default folder.

@ACTCD
Copy link
Collaborator

ACTCD commented Sep 29, 2024

@Morac2

Yes, I use macOS Sequoia 15.0, I think this happened before the update already though.

I'm seeing the same problem after upgrading to MacOS 15.0.

This was never an issue on prior versions of MacOS.

I'm sorry, but the issues you are experiencing appear to be inconsistent.

Let’s not lump all the issues and options together.

@thegcat raise two main issues here:

  • iCloud save location regularly reset (issue 1)
  • save location impossible to change (issue 2)

"keep downloaded" is a new feature in macOS 15 / iOS 18 and I think it should help alleviate "issue 1" if iCloud is indeed deleted and re-created the folder behind the scenes (e.g. eviction due to space optimization).

So did you encounter "issue 1" when "keep downloaded" option was enabled or when it was disabled?


It should be noted that, my previous comment about macOS 15 was only about "issue 2" and I had wondered if "issue 2" only happened in macOS 15. But now that I have investigated clearly, that has nothing to do with the problem I found.


So, for "issue 1", we create a "bookmark" for the folder you selected (outside of the app sandbox) to maintain access to the folder, but if the "bookmark" becomes invalid (e.g. the folder was deleted and then re-created), we lose access to the folder (without the bookmark, the app cannot access folders outside the sandbox), so you may see it revert to the default path.

For "issue 1", I don't have much help at the moment since I can't debug iCloud.

For "issue 2", if you could reproduce it stably and provide some necessary information or logs, I will try to solve it.

I hope this time I have made things clear.

@Morac2
Copy link

Morac2 commented Sep 29, 2024

I have the issue where the User Script save location keeps changing from the custom I set to to back to the default location. This started with MacOS 15.

I set it to /Users/username/Documents/UserScripts/ and it gets changed back to /Users/username/Library/Containers/com.userscripts.macos.Userscripts-Extension/Data/Documents/scripts every now and then (usually after restarting my Mac).

I'm not sure if that is what you are calling the "iCloud Save location" issue, though I do have the Documents folder syncing to iCloud.

Of note, I checked and User Scripts does not have permission to access the Documents folder, but I was never prompted to allow access and it seems to work without needing that. Maybe Safari extensions don't need that, but any other app that tries to access Documents requires me giving permission.

I don't have "issue 2".

@ACTCD
Copy link
Collaborator

ACTCD commented Sep 29, 2024

@Morac2 The macOS stuff is just confusing, isn’t it?

Compared to its advertised safety, it just makes it impossible for people to know what it is doing behind the scenes.

The first thing to be clear about is that if you don't authorize an app to access your "documents" folder, they really can't.

And Userscripts never requested permission to access the "Documents" folder, so you won't find it in the list.

But why does it have access to the folder you selected in "Documents" folder? Because you "selected" it.

This is another authorization mechanism in macOS, which means that the App can access the files or folders you provide or selected through the system "open and save panels". If you want to know the details, here is the official documentation.

I'm not sure if that is what you are calling the "iCloud Save location" issue, though I do have the Documents folder syncing to iCloud.

I don't know what it does to your folder when you turn on iCloud sync for the "Documents" folder, since I don't use iCloud. But if the same thing doesn't happen when you select a non-iCloud synced folder, you know what's probably going on.

As I explained above, The app uses the "bookmark" to access folder of your selected, and if that "bookmark" becomes invalid, the "restore to default path" situation what you describe may occur.

If you want to see what's going on behind the scenes, such as whether the bookmark has invalid and what the app has tried, please refer to the method I provided above for viewing system and app logs.

Since the app and extension do not collect any usage data, without any logs or details or reproducible actions, we cannot provide any further help.

@thegcat
Copy link
Author

thegcat commented Sep 29, 2024

Both problems are probably not related, I would open a new issue for the iCloud-related issue regarding iCloud on macOS 15?

Regarding the issue of not being able to change the "Save Location" on macOS, I have captured console logs of the activity when it doesn't work:

log
standard	15:26:09.312664+0200	Userscripts	[0x13ea28530] activating connection: mach=false listener=false peer=false name=(anonymous)
standard	15:26:09.313527+0200	Userscripts	[0x60000008c000] activating connection: mach=false listener=false peer=false name=com.apple.appkit.xpc.openAndSavePanelService
standard	15:26:09.313815+0200	Userscripts	[0x60000008c000] invalidated after the last release of the connection object
standard	15:26:09.313903+0200	Userscripts	[0x13ec3e350] activating connection: mach=false listener=false peer=false name=(anonymous)
standard	15:26:09.572413+0200	Userscripts	Advance to run phase.
standard	15:26:09.655674+0200	Userscripts	order window front conditionally: 861 related: 0
standard	15:26:09.655863+0200	Userscripts	parent NSWindow 0x13ed0a2b0 (861) remove NSOpenPanel 0x13ea194e0 (88f) from group
standard	15:26:09.655951+0200	Userscripts	parent NSWindow 0x13ed0a2b0 (861) add NSOpenPanel 0x13ea194e0 (88f) to group
standard	15:26:09.657180+0200	Userscripts	order window: 88f op: 1 relative: 861 related: 0
standard	15:26:09.919214+0200	Userscripts	parent NSWindow 0x13ed0a2b0 (861) remove NSOpenPanel 0x13ea194e0 (88f) from group
standard	15:26:09.919326+0200	Userscripts	parent NSWindow 0x13ed0a2b0 (861) add NSOpenPanel 0x13ea194e0 (88f) to group
standard	15:26:09.919469+0200	Userscripts	order window: 88f op: 1 relative: 861 related: 0
standard	15:26:16.785773+0200	Userscripts	[0x60000009a670] activating connection: mach=true listener=false peer=false name=com.apple.scopedbookmarksagent.xpc
standard	15:26:16.793132+0200	Userscripts	[0x60000009a670] invalidated after the last release of the connection object
fehler	15:26:16.793224+0200	Userscripts	createBookmark(_:_:) - The file couldn’t be opened.
standard	15:26:16.796153+0200	Userscripts	order window front conditionally: 861 related: 0
standard	15:26:17.057543+0200	Userscripts	parent NSWindow 0x13ed0a2b0 (861) remove NSOpenPanel 0x13ea194e0 (88f) from group
standard	15:26:17.058490+0200	Userscripts	order window: 88f op: 0 relative: 0 related: 0
standard	15:26:17.060962+0200	Userscripts	[0x13ea28530] invalidated because the current process cancelled the connection by calling xpc_connection_cancel()
standard	15:26:17.060976+0200	Userscripts	[0x13ec3e350] invalidated because the current process cancelled the connection by calling xpc_connection_cancel()

"fehler" means error.

@thegcat
Copy link
Author

thegcat commented Sep 29, 2024

As an additional data point: This happens even for folders that are in my home directory and that are not the Documents folder for example.

@ACTCD
Copy link
Collaborator

ACTCD commented Sep 29, 2024

@thegcat

I would open a new issue for the iCloud-related issue regarding iCloud on macOS 15?

So, could you clarify, which issue only occurs in macOS 15, and which one also occurs in macOS 14 ?

I would rather you create a separate issue for "save location impossible to change (issue 2)".

Because the discussion and description in this issue are more about "issue 1".

I have captured console logs of the activity when it doesn't work

The log has almost no context. I can guess where the error print, but it's not much help.

It just calls the system API to create a "bookmark", like I said above.

private func createBookmark(_ url: URL, _ withSecurityScope: Bool) -> Data? {
do {
return try url.bookmarkData(
options: withSecurityScope ? .withSecurityScope : [],
includingResourceValuesForKeys: nil,
relativeTo: nil
)
} catch {
logger?.error("\(#function, privacy: .public) - \(error.localizedDescription, privacy: .public)")
}
return nil
}

But we still don’t know why it throws "The file couldn’t be opened.", we can't even know in which process it happened.

The func is called in multiple processes, it might be more helpful if you could get a more complete logs.

For example, under normal circumstances you may find the following logs:

updateBookmark() - setterId not exist: ScriptsDirectoryUrlBookmarkData
wrappedValue - try get bookmark: ScriptsDirectoryUrlBookmarkData
wrappedValue - bookmark not exist: ScriptsDirectoryUrlBookmarkData
wrappedValue - try set bookmark: ScriptsDirectoryUrlBookmarkData file:///Users/username/folder1/
wrappedValue - try get bookmark: ScriptsDirectoryUrlBookmarkData

This happens even for folders that are in my home directory and that are not the Documents folder for example.

If that's a local folder (no iCloud involved), I don't think there's any difference in "Documents" or other locations, at this point.

@ACTCD
Copy link
Collaborator

ACTCD commented Sep 29, 2024

Regarding "issue 1", I now have some new information, but I would still like to get your reproduction and error message logs to confirm this.

I think one possibility is that we couldn't access the folder while iCloud was syncing it, so the "bookmark" couldn't resolve at that point, and we then deemed the "bookmark" invalid and deleted it.

You should be able to find the following logs:

error	Userscripts-Mac-Safari-Extension	resolvBookmark(_:_:_:) - ???
info	Userscripts-Mac-Safari-Extension	removeBookmark() - remove invalid bookmark: ScriptsDirectoryUrlBookmarkData

But I need error messages marked with question marks to confirm the conjecture and identify specific errors.

This "error" should be found in the historical system logs, which means there is no need for instant monitoring and reproduction.

So please run the command below in Terminal.app and send the generated userscripts-log.txt file here.

log show --start 2024-09-01 --predicate 'process="Userscripts-Mac-Safari-Extension" && category="Userscripts_Mac_Safari_Extension/Preferences.swift"' --info --debug > userscripts-log.txt

If the issue is as I guessed, then we need some asynchronous detection like @2xsaiko tried using NSFileCoordinator in #629, and design a new synchronization mechanism to completely solve the issues.

@thegcat
Copy link
Author

thegcat commented Sep 30, 2024

I have attached the log, but it seems there's not much history to go by. I'll try to provide one when Userscripts forgets the folder again.

userscripts-log.txt

@ACTCD
Copy link
Collaborator

ACTCD commented Sep 30, 2024

It is worth mentioning that the error logs will persist on the hard disk for a period of time, but the debug or info logs will only exist in memory and is volatile.

@thegcat
Copy link
Author

thegcat commented Oct 1, 2024

I have a log, it has the line you expected.
userscripts-log.txt

@ACTCD
Copy link
Collaborator

ACTCD commented Oct 1, 2024

@thegcat While the error still doesn't provide enough information, such as why "the file cannot be opened", but it basically confirms my suspicion that there was some "time" when the iCloud folder couldn't be read. (e.g. it might be syncing; it can't read synchronously)

As far as I know, Apple introduced the FileProvider mechanism to iCloud Drive in macOS 14, which is asynchronous.

Currently, we may not have an easy way to solve this issue. As I mentioned above, we must redesign a caching and synchronization mechanism to completely solve the issues.

Before we solve the issue, as a possible self-workaround, you might consider setting a local path (rather than any via the FileProvider). Then sync the content to the cloud folder manually, or via tools/scripts/automation etc.

@thegcat
Copy link
Author

thegcat commented Oct 1, 2024

This is no problem, I can switch to the builtin/online sync solution for the time being. If there's anything I can check to clarify what iCloud does (watch the node id, try to access the file every second or whatever) I could to that, but that might be useless if the file access mechanism will be changed?

@ACTCD
Copy link
Collaborator

ACTCD commented Oct 1, 2024

@thegcat Thanks, but we can almost assume that the issues arises from the FileProvider state.
Debugging iCloud is a difficult and troublesome thing.
In any case I think our future refactoring should improve this.

If there is more new information or logs about "issue 2", please provide it to us.

@Morac2
Copy link

Morac2 commented Oct 6, 2024

For me, I don't see anything about bookmarks in the logs when the folder resets to the default value. The only errors I see are:

Userscripts-Mac-Safari-Extension: (PlugInKit) [com.apple.PlugInKit:subsystems] Bootstrapping; external subsystem UIKit_PKSubsystem refused setup

Userscripts-Mac-Safari-Extension: (CoreFoundation) [com.apple.defaults:User Defaults] Couldn't read values in CFPrefsPlistSource<0x12a00ff10> (Domain: J74Q8V8V8N.com.userscripts.macos, User: kCFPreferencesAnyUser, ByHost: Yes, Container: (null), Contents Need Refresh: Yes): Using kCFPreferencesAnyUser with a container is only allowed for System Containers, detaching from cfprefsd

@ACTCD
Copy link
Collaborator

ACTCD commented Oct 6, 2024

@Morac2 Have you enabled "Enable Native Logger"?

These logs are not helpful.

@blalor
Copy link

blalor commented Oct 8, 2024

I'm on macOS 15.0, Userscripts Version 4.5.4 (109). I'm having a similar problem, but changing the folder never succeeds. Screen capture and logs attached (although streaming logs didn't show anything which is pretty weird).

Screen.Recording.2024-10-08.at.6.44.51.AM.480p.mov

userscripts-log-show.txt
userscripts-log-stream.txt

@ACTCD
Copy link
Collaborator

ACTCD commented Oct 8, 2024

@blalor The log filter is for "iCloud save location regularly reset (issue 1)", so you missed the change path part of the log.

Please try to get a more extensive log:

log show --start 2024-10-01 --predicate 'process BEGINSWITH "Userscripts"' --info --debug > userscripts-log.txt

@Morac2
Copy link

Morac2 commented Oct 12, 2024

I'm now seeing the same problem with "issue 2". I can't change the path to anything other than the default. I dumped the log from right after selecting "open" when trying to change the folder:

Timestamp                       Thread     Type        Activity             PID    TTL  
2024-10-12 00:23:20.006867-0400 0x2decf0   Activity    0x171dd68            46119  0    Userscripts: (RunningBoardServices) didChangeInheritances
2024-10-12 00:23:20.013534-0400 0x2dde85   Default     0x0                  46119  0    Userscripts: (AppKit) [com.apple.AppKit:Window] order window front conditionally: 2a41 related: 0
2024-10-12 00:23:20.013643-0400 0x2dde85   Default     0x0                  46119  0    Userscripts: (AppKit) [com.apple.AppKit:Window] order window: 2a26 op: -1 relative: 2a41 related: 0
2024-10-12 00:23:20.013722-0400 0x2dee75   Activity    0x171dd69            46119  0    Userscripts: (RunningBoardServices) didChangeInheritances
2024-10-12 00:23:20.015635-0400 0x2dde85   Default     0x0                  46119  0    Userscripts: (AppKit) [com.apple.AppKit:Window] order all windows front 224104838327833
2024-10-12 00:23:20.016296-0400 0x2dde85   Info        0x0                  46119  0    Userscripts: (LaunchServices) [com.apple.launchservices:cas] information in shared memory for 0x0-0x10010 with seed 579 was still valid, so using cached info { "ApplicationType"="BackgroundOnly", , "BuildMachineOSBuild"="22A380021", , "BundleIdentifierLowerCase"="com.apple.viewbridgeauxiliary", , "CFBundleExecutable"="ViewBridgeAuxiliary", , "CFBundleExecutablePath"="/System/Library/PrivateFrameworks/ViewBridge.framework/Versions/A/XPCServices/ViewBridgeAuxiliary.xpc/Contents/MacOS/ViewBridgeAuxiliary", , "CFBundleExecutablePathDeviceID"=16777234, , "CFBundleExecutablePathINode"=1152921500312405533, , "CFBundleIdentifier"="com.apple.ViewBridgeAuxiliary", , "CFBundleInfoDictionaryVersion"="6.0", , "CFBundleName"="ViewBridgeAuxiliary", , "CFBundleNameLowerCase"="viewbridgeauxiliary", , "CFBundlePackageType"="XPC!", , "CFBundleSignature"="????", , "CFBundleSupportedPlatforms"=( "MacOSX"), , "ChangeCount"=579, , "DTCompiler"="com.apple.compilers.llvm.clang.1_0", , "DTPlatformBuild"="", , "DTPlatformName"="macosx", , "DTPlatformVersion"="15.0", , "DTSDKBuild"="24A314", , "DTSDKName"="macosx15.0.internal", , "DTXcode"="1600", , "DTXcodeBuild"=<…>
2024-10-12 00:23:20.017707-0400 0x2dde85   Info        0x0                  46119  0    Userscripts: (AE) [com.apple.appleevents:receive] RECEIVED:(aevt,rapp) {aevt,rapp target=Dock  returnID=7371}...
2024-10-12 00:23:20.078519-0400 0x2dee75   Activity    0x171dd6d            46119  0    Userscripts: (RunningBoardServices) didChangeInheritances
2024-10-12 00:23:20.112554-0400 0x2dee75   Activity    0x171dd6e            46119  0    Userscripts: (RunningBoardServices) didChangeInheritances
2024-10-12 00:23:21.749525-0400 0x2dde85   Info        0x171e03f            46119  0    Userscripts: (AppKit) [com.apple.AppKit:Window] window 2a26 end modal sheet 2a41
2024-10-12 00:23:21.749828-0400 0x2dde85   Info        0x171e03f            46119  0    Userscripts: (CoreServicesInternal) [com.apple.FileURL:bookmark] ShouldForceRevocable: false, not a Mac Catalyst app
2024-10-12 00:23:21.750012-0400 0x2dde85   Info        0x171e03f            46119  0    Userscripts: (CoreServicesInternal) [com.apple.FileURL:bookmark] ShouldForceRevocable: false, security scope requested
2024-10-12 00:23:21.750453-0400 0x2dde85   Default     0x171e03f            46119  0    Userscripts: (libxpc.dylib) [com.apple.xpc:connection] [0x6000018b8d20] activating connection: mach=true listener=false peer=false name=com.apple.scopedbookmarksagent.xpc
2024-10-12 00:23:21.752646-0400 0x2dde85   Default     0x171e03f            46119  0    Userscripts: (libxpc.dylib) [com.apple.xpc:connection] [0x6000018b8d20] invalidated after the last release of the connection object
2024-10-12 00:23:21.753988-0400 0x2dde85   Default     0x171e03f            46119  0    Userscripts: (AppKit) [com.apple.AppKit:Window] order window front conditionally: 2a26 related: 0
2024-10-12 00:23:22.015734-0400 0x2dde85   Default     0x171e03f            46119  0    Userscripts: (AppKit) [com.apple.AppKit:Window] parent NSWindow 0x139b14b00 (2a26) remove NSOpenPanel 0x13994a8a0 (2a41) from group
2024-10-12 00:23:22.018474-0400 0x2dde85   Default     0x171e03f            46119  0    Userscripts: (AppKit) [com.apple.AppKit:Window] order window: 2a41 op: 0 relative: 0 related: 0
2024-10-12 00:23:22.023747-0400 0x2dde85   Default     0x0                  46119  0    Userscripts: (libxpc.dylib) [com.apple.xpc:connection] [0x1399428c0] invalidated because the current process cancelled the connection by calling xpc_connection_cancel()
2024-10-12 00:23:22.023754-0400 0x2dde85   Default     0x0                  46119  0    Userscripts: (libxpc.dylib) [com.apple.xpc:connection] [0x139b1c210] invalidated because the current process cancelled the connection by calling xpc_connection_cancel()
2024-10-12 00:23:22.023798-0400 0x2dde85   Info        0x0                  46119  0    Userscripts: (AppKit) [com.apple.AppKit:Window] context (d1d4cf54 -> 0) for window 2a41
2024-10-12 00:23:22.678989-0400 0x2dee75   Activity    0x171e461            46119  0    Userscripts: (RunningBoardServices) didChangeInheritances
2024-10-12 00:23:22.729552-0400 0x2dee75   Activity    0x171e462            46119  0    Userscripts: (RunningBoardServices) didChangeInheritances


defaults read com.userscripts.macos
{
    NSNavLastRootDirectory = "~/Documents";
    NSNavPanelExpandedSizeForOpenMode = "{800, 448}";
    "NSWindow Frame NSNavPanelAutosaveName" = "320 335 800 448 0 0 1440 875 ";
    "changeSaveLocation - NSNavPanelExpandedSizeForOpenMode" = "{800, 448}";
    "changeSaveLocation - NSNavPanelFileLastListModeForOpenModeKey" = 3;
    "changeSaveLocation - NSNavPanelFileListModeForOpenMode2" = 3;
    "changeSaveLocation - NSOSPLastRootDirectory" = {length = 752, bytes = 0x626f6f6b f0020000 00000410 30000000 ... 90010000 00000000 };
    "changeSaveLocation - NSOSPShowsSidebar" = 1;
}

@Morac2
Copy link

Morac2 commented Oct 12, 2024

I noticed another application I ran that I set a different directory for the default location (external drive) was also defaulting to the ~/Library/Containers/... folder. I restarted my Mac and then I could change the UserScript folder.

I first noticed this with macOS Sequoia so I think this is a bug in Sequoia.

@blalor
Copy link

blalor commented Oct 12, 2024

Same, after upgrading to macOS 15.0.1 (or maybe just due to restarting after that upgrade?) I can now select the desired folder.

@ACTCD
Copy link
Collaborator

ACTCD commented Oct 12, 2024

@Morac2 I edited your comments to better format and remove incorrect references.

I looked at your logs, but it doesn't contain any useful information, and there doesn't appear to be any log entries produced by the App's internal Logger.

As I replied above, either you may not have the "Enable Native Logger" option turned on, or you may be using an incorrect log collection method.

Without relevant logs, it is really difficult for us to analyze possible issues. I'm trying to build a built-in log export functionality that I hope will help and simplify the process.

Additional question: Does the "Cannot change save location" only occur when trying to change to iCloud/External Drive, or does it also apply to any local disk path?

Because iCloud/External Drive may all be driven by FileProvider, I suspect the possible reason is that the selected path cannot be read immediately, so the bookmark is deleted immediately.

I've added readability detection in #734 but haven't released a new version yet, maybe I should release one so at least it will have a popup.

@ACTCD
Copy link
Collaborator

ACTCD commented Oct 12, 2024

Here you go, try v5.0.0-beta.4 to see if an error pop-up window will be displayed ("Cannot read the specified path; please choose a different one.") when the path cannot be changed.

But, of course, it's always nice to see a more detailed associated error log.

@Morac2
Copy link

Morac2 commented Oct 13, 2024

@ACTCD I’m almost certain this is a MacOS 15 bug as I’ve seen another application have the same problem where I can’t change the default folder to any folder until I restart my Mac. That happens every few days. When it happened I noticed that UserScripts reverted to the default folder as well.

@ACTCD
Copy link
Collaborator

ACTCD commented Oct 13, 2024

@Morac2 I know it comes with macOS 15.
But just because other apps encounter the same issue doesn't mean it's a system "bug".
I'd still like to know what's going on and what the error log is.
It could be a system change that affects different applications of the same or similar implementation.

In other words, this is not enough to prove that it is a system bug, maybe it is a "feature".
Like I mentioned Apple has completely switched iCloud to async FileProvider driver.
If it is what I said, don't expect Apple to fix it, the only possibility is for each App to adapt to the new system features.

@ACTCD
Copy link
Collaborator

ACTCD commented Oct 18, 2024

Bringing some updates, possible source of both issues:

https://forums.developer.apple.com/forums/thread/764435

What you're hitting is bug in "ScopedBookmarksAgent" which can cause it hang if it happens to have been launched when the keychain was also locked (for example, late in the screen lock process). That bug is fixed as of macOS 15.1 beta 4.

If you're hitting it regularly during development, you can resolve the issue by killing ScopedBookmarksAgent (you may also need to kill and relaunch your app, depending on what state it ends up). On the user side, a log out (or reboot) should resolve the issue.

__
Kevin Elliott
DTS Engineer, CoreOS/Hardware

So @Morac2 might be right, this might be the system bug and have been fixed as of macOS 15.1 beta 4.

@jeremy-w
Copy link

I've never encountered a folder location reset on macOS (still running Sonoma 14.6.1 here), but I started seeing it on iOS after one of the 18.x releases. I initially set it to Keep Downloaded when some files were not there to modify the site, but then it kept resetting to the default location. The folder is a Keep Downloaded folder, so definitely going nowhere. I've currently given up and am just manually syncing the files I've changed from the iCloud location to the On my iPhone Userscripts folder.

I haven't checked the code yet, but if the app is using UserDefaults, then this bug identified by Christian Selig might be at play. Their workaround was to switch to their own library, TinyStorage, for the info they formerly stored in UserDefaults.

@ACTCD
Copy link
Collaborator

ACTCD commented Oct 25, 2024

@jeremy-w I don't think UserDefaults is a issue in this use case, we are not storing sensitive or large amounts of data.

The problem is that we need logs to determine why the bookmark was reset.

For example it cannot be read, or is no longer valid.

@jeremy-w
Copy link

jeremy-w commented Oct 25, 2024 via email

@thegcat
Copy link
Author

thegcat commented Oct 25, 2024

Bringing some updates, possible source of both issues:

forums.developer.apple.com/forums/thread/764435

I've been running the 15.1 public beta for a few days and I can report I have not seen the Save Location resetting. I have checked twice in that timeframe and both times I could also change the Save Location without any issues.

It seems this one can be added to the "things breaking in .0 releases for no apparent reason" pile, sorry for the hassle.

@ACTCD
Copy link
Collaborator

ACTCD commented Oct 25, 2024

Starting with iOS 15, iOS will sometimes wake up your application early...
I’m just sad that this lovely, simple API has some really sharp edges in 2024.

@jeremy-w iOS 15 was released in 2021, I don't understand why it says the problem becomes sharp in 2024, and why is it related to iOS 18 again?

So, in my opinion, it would be nice to knowledge it, but I wouldn't guess it's relevant to the issue.

@ACTCD
Copy link
Collaborator

ACTCD commented Oct 25, 2024

@thegcat Thanks for confirming. We'll keep this issue open until people can transition to the fixed OS versions.

@dotsam
Copy link

dotsam commented Oct 25, 2024

On 15.0, I can fix the issue with a killall -HUP ScopedBookmarkAgent as suggested in the Apple developer forums

@ACTCD
Copy link
Collaborator

ACTCD commented Oct 25, 2024

@dotsam Thanks for confirming. It looks like we'll just have to wait for macOS 15.1 to be officially released.

@ACTCD
Copy link
Collaborator

ACTCD commented Nov 6, 2024

This should be fixed in macOS 15.1, which was released a week ago.
Closed as an upstream issue.

@ACTCD ACTCD closed this as completed Nov 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
need reproduce Need reproduce or more information
Projects
None yet
Development

No branches or pull requests

6 participants