steilerDev / icloud-photos-sync

One-way sync engine for the iCloud Photos Library into the native file system
https://icps.steiler.dev/
GNU General Public License v3.0
337 stars 9 forks source link

Maximum call stack size exceeded #230

Closed jasonwaters closed 11 months ago

jasonwaters commented 1 year ago

Checklist before opening an issue

Describe the bug

During the initial sync, I am getting a fatal error.

Loading local & fetching remote iCloud Library state...
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Experienced fatal error at 3/26/2023, 8:05:04 PM: APP_SYNC (FATAL): Sync failed caused by ICLOUD_PHOTOS_FETCH_RECORDS (FATAL): Unable to fetch records (album 'All photos') caused by Maximum call stack size exceeded (Error Code: 65409072-1365-41db-8768-a0541fa471e2)
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

I have a very large photo library with more than 144K photos and 5K videos. Most assets are in my shared library which I converted from a personal library i've used for years. I have many albums, some of them nested within folders.

The error occurs when fetching the SharedLibrary assets. In fact, I cloned the repo and prevented the shared library from syncing and everything synced great for my personal library.

Error code

Error Code generated upon the crash: 65409072-1365-41db-8768-a0541fa471e2

Logs

find the log file here

Operating environment

jasonwaters commented 1 year ago

One problem I noticed that is unrelated to this issue is that when syncing, the script fetches assets for each album. But what I observed is that it does this for the shared library as well -- for every album. However instead of fetching the shared library assets for the album (which i don't think is yet supported in apple's api) it fetches all shared library assets for the album "All Photos". So in my case, it re-fetches the shared library "All Photos" assets dozens of times -- once for each album i have.

here is an excerpt from my log. notice it is fetching records for a specific album, but the subsequent lines show it's building queries for records of album "All photos in SharedLibrary"

[2023-03-29T04:41:31.763Z] DEBUG i-Cloud-Photos: Fetching all picture records for album DEFA6DB7-CA88-40D4-96E0-61159A6B4ED5 for shared zone
[2023-03-29T04:41:32.102Z] DEBUG i-Cloud-Photos: Expecting 132851 records for album All photos in SharedLibrary library, executing 1342 queries
[2023-03-29T04:41:32.102Z] DEBUG i-Cloud-Photos: Building query for records of album All photos in SharedLibrary library at index 0
[2023-03-29T04:41:32.104Z] DEBUG i-Cloud-Photos: Building query for records of album All photos in SharedLibrary library at index 99
[2023-03-29T04:41:32.104Z] DEBUG i-Cloud-Photos: Building query for records of album All photos in SharedLibrary library at index 198
[2023-03-29T04:41:32.104Z] DEBUG i-Cloud-Photos: Building query for records of album All photos in SharedLibrary library at index 297
[2023-03-29T04:41:32.104Z] DEBUG i-Cloud-Photos: Building query for records of album All photos in SharedLibrary library at index 396
lonevvolf commented 1 year ago

I also have this issue. I have an extremely large library (around 300k items) - part of the reason I am trying to back it up so I can possibly start fresh without losing my photos. Similar to @jasonwaters I have moved all items to the Shared Library except for a few.

steilerDev commented 11 months ago

Should be released and fixed with v1.2.0 - closing this for now, please create a new ticket in case this happens again.