Skip to content

fix(android): use app cache dir for saveToTempFile#1199

Open
msluszniak wants to merge 1 commit into
mainfrom
@ms/fix-android-temp-dir
Open

fix(android): use app cache dir for saveToTempFile#1199
msluszniak wants to merge 1 commit into
mainfrom
@ms/fix-android-temp-dir

Conversation

@msluszniak
Copy link
Copy Markdown
Member

@msluszniak msluszniak commented May 28, 2026

Description

std::filesystem::temp_directory_path() resolves $TMPDIR to /data/local/tmp on Android <13. App processes can't write there, so every saveToTempFile call path (style transfer, text-to-image) fails with code: 103, "Failed to save the image: /data/local/tmp/rn_executorch_*.png".

This PR pipes the platform-provided app cache directory (reactApplicationContext.cacheDir on Android, NSTemporaryDirectory() on iOS) through injectJSIBindings and uses it in saveToTempFile instead of std::filesystem::temp_directory_path().

Introduces a breaking change?

  • Yes
  • No

Type of change

  • Bug fix (change which fixes an issue)
  • New feature (change which adds functionality)
  • Documentation update (improves or adds clarity to existing documentation)
  • Other (chores, tests, code style improvements etc.)

Tested on

  • iOS
  • Android

Testing instructions

  1. Run the computer-vision example app on an Android 12 device (or earlier). If you don't have any, please contact me.
  2. Open the Style Transfer demo, pick an image, run the model.
  3. Verify the styled image is saved and displayed without the code: 103 error.
  4. Sanity-check on iOS and a newer Android (13+) to confirm no regression.

Related issues

Fixes #962

std::filesystem::temp_directory_path() resolves $TMPDIR to /data/local/tmp
on Android <13, which app processes can't write — breaking style transfer
and text-to-image. Pipe reactApplicationContext.cacheDir (Android) /
NSTemporaryDirectory() (iOS) through injectJSIBindings instead.

Fixes #962
@msluszniak msluszniak self-assigned this May 28, 2026
@msluszniak msluszniak added platform: android Issues and tasks related to Android bug fix PRs that are fixing bugs labels May 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug fix PRs that are fixing bugs platform: android Issues and tasks related to Android

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Problems with using temporary storage on Android 12

1 participant