Skip to content

Conversation

@nigelgrange
Copy link

@nigelgrange nigelgrange commented Oct 27, 2025

Two changes that address issues I've encountered when transferring a large number of audio/video files from an iOS device - approx 600 files with a combined size of around 60GB. The downloads were much slower than using Xcode, and if the connection dropped then the transfer was not resumable.

I've increased all data transfer buffer sizes from 4KB to 256KB (64x increase). This significantly improves data transfer speeds from iOS devices.

Changes Made

  1. Download Buffer (ios-deploy.m:2191)
  • Before: char buf[4096] (4KB)
  • After: char buf[262144] (256KB)
  • Impact: Downloads from device to Mac via AFC protocol
  1. LLDB Communication Buffer (ios-deploy.m:1247)
  • Before: char buffer[0x1000] (4KB)
  • After: char buffer[262144] (256KB)
  • Impact: Debugserver communication and app debugging data transfer
  1. File Copy Buffer (ios-deploy.m:1178)
  • Before: char buffer[0x1000] (4KB)
  • After: char buffer[262144] (256KB)
  • Impact: Custom script loading and file operations

Performance Improvement

With 256KB buffers, you should see:

  • Fewer system calls (64x reduction in read/write operations)
  • Reduced overhead from AFC protocol per-call overhead
  • Better throughput especially for large file transfers
  • Estimated speed increase: 10-40x faster depending on file size and USB connection

I've added resume functionality to the download feature in ios-deploy.

Changes Made

Modified the copy_file_callback function in src/ios-deploy/ios-deploy.m:2165-2233 to:

  1. Get remote file size: Before downloading, the code now queries the remote file's size using AFCFileInfoOpen and AFCKeyValueRead to read the st_size attribute.
  2. Check local file: Uses the standard stat() system call to check if a file already exists at the destination path and get its size.
  3. Skip transfer if identical: If both files exist and have the same size, the download is skipped with a message: "filename (skipped - already downloaded)".
  4. Proceed with download otherwise: If the file doesn't exist locally or has a different size, the download proceeds as normal.

How It Works

When downloading from an iOS device using --download:

  • If the connection is interrupted mid-transfer, you can simply re-run the same command
  • Files that were fully downloaded (matching size) will be skipped automatically
  • Partially downloaded files (different size) will be re-downloaded from scratch
  • New files will be downloaded normally

This allows the tool to automatically continue where it left off if the connection is interrupted.

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

Successfully merging this pull request may close these issues.

2 participants