Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

safari app extension crashes after a few seconds for hello world project

  1. open xcode

  2. file > new >project > Cocoa app

  3. file > new > target > safari extension

  4. compile and run extension

  5. select safari.

  6. xcode compiles with no errors.

Safari opens for a few seconds then crashes.

this is the output of the debug window.

2018-10-10 15:27:18.039905-0700 Safari[1020:16719] [SQLiteStore] Failed to acquire database store coordination lock at /Users//Library/Safari/Favicon Cache/favicons.db-lock: [35: Resource temporarily unavailable] 2018-10-10 15:27:18.040155-0700 Safari[1020:16719] [SQLiteStore] Failed to acquire exclusive access to database at file:///Users//Library/Safari/Favicon%20Cache/favicons.db. 2018-10-10 15:27:18.041141-0700 Safari[1020:16719] [SQLiteStore] Failed to acquire database store coordination lock at /Users//Library/Safari/Favicon Cache/favicons.db-lock: [35: Resource temporarily unavailable] 2018-10-10 15:27:18.041226-0700 Safari[1020:16719] [SQLiteStore] Failed to acquire exclusive access to database at file:///Users//Library/Safari/Favicon%20Cache/favicons.db. 2018-10-10 15:27:18.041331-0700 Safari[1020:16719] [SQLiteStore] Falling back to an in-memory store 2018-10-10 15:27:18.042877-0700 Safari[1020:16719] [FaviconPersistence] Using in-memory representation for database /Users//Library/Safari/Favicon Cache/favicons.db 2018-10-10 15:27:18.125466-0700 Safari[1020:16771] [SQLiteStore] Failed to acquire database store coordination lock at /Users//Library/Caches/com.apple.Safari/TabSnapshots/Metadata.db-lock: [35: Resource temporarily unavailable] 2018-10-10 15:27:18.125660-0700 Safari[1020:16771] [SQLiteStore] Failed to acquire exclusive access to database at file:///Users//Library/Caches/com.apple.Safari/TabSnapshots/Metadata.db. 2018-10-10 15:27:18.235987-0700 Safari[1020:16718] flock failed to lock maps file: errno = 35 2018-10-10 15:27:18.236343-0700 Safari[1020:16718] flock failed to lock maps file: errno = 35 2018-10-10 15:27:18.293614-0700 Safari[1020:16718] Failed to acquire exclusive access to AutoFill corrections SQLite store at AutoFillCorrections.db. Failed to acquire exclusive access to AutoFill corrections SQLite store at AutoFillCorrections.db. 2018-10-10 15:27:18.299481-0700 Safari[1020:16718] Failed to acquire exclusive access to AutoFill corrections SQLite store at CloudAutoFillCorrections.db. Failed to acquire exclusive access to AutoFill corrections SQLite store at CloudAutoFillCorrections.db. 2018-10-10 15:27:18.300530-0700 Safari[1020:16718] Failed to acquire exclusive access to AutoFill corrections SQLite store at AutoFillCorrections.db. Failed to acquire exclusive access to AutoFill corrections SQLite store at AutoFillCorrections.db. 2018-10-10 15:27:18.304153-0700 Safari[1020:16718] Failed to acquire exclusive access to AutoFill corrections SQLite store at CloudAutoFillCorrections.db. Failed to acquire exclusive access to AutoFill corrections SQLite store at CloudAutoFillCorrections.db. 2018-10-10 15:27:18.620185-0700 Safari[1020:16763] Failed to acquire exclusive access to AutoFill corrections SQLite store at AutoFillCorrections.db. Failed to acquire exclusive access to AutoFill corrections SQLite store at AutoFillCorrections.db. 2018-10-10 15:27:18.623032-0700 Safari[1020:16773] [CrowdsourcedAutoFill] Unable to read cloud AutoFill correction sets, error: Error Domain=NSCocoaErrorDomain Code=260 "The file couldn’t be opened because it doesn’t exist." 2018-10-10 15:27:18.629453-0700 Safari[1020:16763] Failed to acquire exclusive access to AutoFill corrections SQLite store at CloudAutoFillCorrections.db. Failed to acquire exclusive access to AutoFill corrections SQLite store at CloudAutoFillCorrections.db. 2018-10-10 15:27:18.675086-0700 Safari[1020:16765] [CloudBookmarks] Error fetching remote migration state: Error Domain=com.apple.SafariBookmarksSync.CloudBookmarksErrorDomain Code=0 "(null)" 2018-10-10 15:27:18.771588-0700 Safari[1020:16718] [RemotePlistController] The downloaded plist could not be loaded: Error Domain=NSCocoaErrorDomain Code=260 "The file couldn’t be opened because it doesn’t exist." 2018-10-10 15:27:19.161007-0700 Safari[1020:16773] Failed to acquire exclusive access to AutoFill corrections SQLite store at AutoFillCorrections.db. Failed to acquire exclusive access to AutoFill corrections SQLite store at AutoFillCorrections.db. 2018-10-10 15:27:19.167933-0700 Safari[1020:16773] Failed to acquire exclusive access to AutoFill corrections SQLite store at CloudAutoFillCorrections.db. Failed to acquire exclusive access to AutoFill corrections SQLite store at CloudAutoFillCorrections.db. 2018-10-10 15:27:19.279743-0700 Safari[1020:16763] [RemotePlistController] The downloaded plist could not be loaded: Error Domain=NSCocoaErrorDomain Code=260 "The file couldn’t be opened because it doesn’t exist." 2018-10-10 15:27:20.064438-0700 Safari[1020:16763] Failed to acquire exclusive access to AutoFill corrections SQLite store at AutoFillCorrections.db. Failed to acquire exclusive access to AutoFill corrections SQLite store at AutoFillCorrections.db. 2018-10-10 15:27:20.081337-0700 Safari[1020:16763] Failed to acquire exclusive access to AutoFill corrections SQLite store at CloudAutoFillCorrections.db. Failed to acquire exclusive access to AutoFill corrections SQLite store at CloudAutoFillCorrections.db. 2018-10-10 15:27:20.084003-0700 Safari[1020:16763] [CrowdsourcedAutoFill] Neither local nor cloud classification correction databases could be opened Program ended with exit code: 0

I've tried restarting my computer.

I've tried cleaning the project.

I've tried deleting meta data with

xatter -cr .

I've tried all three at once.

like image 860
Travis Rivera Avatar asked Oct 10 '18 22:10

Travis Rivera


People also ask

Why are Extensions not working Safari?

Check Safari extensions If you installed any Safari extensions, make sure that they are up to date. You can also try turning extensions off. From the menu bar in Safari, choose Safari > Preferences. Click Extensions, then deselect the checkbox for each extension to turn it off.

Are Safari extension Safe?

Since you can only install Apple-approved extensions on Safari, the only place to get them is from the Mac App Store. This means every Safari extension is safe to use and automatically updates with other apps on your Mac.


1 Answers

Xcode debugger has a tendency to kill the extension process if it doesn't receive any events from the content script. From my observations, this is completely okay, and in production your app will not die as easily (edited: this isn't true, look at the bottom of the post).

To circumvent this behavior you might want to add this snippet to your script.js:

setInterval(() => safari.extension.dispatchMessage("ping", {}), 1000);

It will make content script send a message named "ping" to the extension every second. This should be enough to keep your extension alive. Again, this is only really needed for debugging, your production build won't need this line to work reliably (edited: this isn't true, look at the bottom of the post).

Keep in mind that by default content scripts are only injected on *.webkit.org pages. This is determined by the value of SFSafariToolbarItem property in your extension's Info.plist file. For testing purposes, you might want to enable your extension on all websites like so:

<key>SFSafariWebsiteAccess</key>
<dict>
  <key>Level</key>
  <string>All</string>
</dict>

Be careful, content script is not injected into an empty tab, so be sure to load some remote page.

UPDATE

Apparently, Safari actually kills extensions in production builds the same way as it does in the debugger. So setInterval() hack is still relevant in that case. This only applies to extensions without a popover.

like image 70
Anton Istomin Avatar answered Jan 03 '23 03:01

Anton Istomin