Skip to content

iOS 26 Media elements fail to load/play local files. #1564

@sonlichao

Description

@sonlichao

Bug Report

Problem

What is expected to happen?

Local media files should be accessible via fileEntry.toURL() URLs in HTML media elements (video, audio, img) on iOS 26, maintaining backward compatibility with existing Cordova apps.

What does actually happen?

On iOS 26, fileEntry.toURL() returns file:/// URLs that cannot be loaded in media elements. The browser console shows:

WebContent[3,768] Could not create a sandbox extension for '<private>'
Media elements fail to load/play local files.

Information

Command or Code

// Save file using cordova-plugin-file
window.resolveLocalFileSystemURL(cordova.file.tmpDirectory, (dirEntry) => {
    dirEntry.getFile(fileName, { create: true }, (fileEntry) => {
        fileEntry.createWriter((fileWriter) => {
            fileWriter.onwriteend = () => {
                // Get URL using official API
                const fileURL = fileEntry.toURL();
                console.log(fileURL); 
                // Output: file:///var/mobile/Containers/Data/Application/.../tmp/video.mp4
                
                // This fails on iOS 26 with sandbox error
                document.getElementById('videoElement').src = fileURL;
            };
            fileWriter.write(blob);
        });
    });
});

Environment, Platform, Device

Platform: iOS 26.0
Device: iPhone SE (3rd generation)
WebView: WKWebView (default)
Configuration: Default Cordova setup (no custom scheme/hostname)

Version information

Cordova CLI: 12.0.0
Cordova iOS: [7.1.0]
Cordova Plugin File: 8.1.3

Additional Context
Working Configuration (with critical side effect):
Adding scheme configuration makes file URLs work:

<preference name="scheme" value="app" />
<preference name="hostname" value="localhost" />

However, this causes complete data loss:

Then toURL() returns: app://localhost/app_file/... (works)
However, this causes complete data loss:

  • Origin changes from null to app://localhost
  • All localStorage, IndexedDB, cookies are permanently lost
  • No migration path exists for user data

This creates an impossible choice:

Keep app working without scheme = No file access on iOS 26
Add scheme configuration = Lose all user data

Tested Scenarios

✅ Same code works on iOS18 and earlier
✅ Same code works on all Android versions
❌ Manual URL conversion file:// to app:// fails (CSP error)
❌ File URLs fail in all locations (tmp, documents, cache)

Checklist

  • I searched for existing GitHub issues
  • I updated all Cordova tooling to most recent version
  • I included all the necessary information above

Metadata

Metadata

Assignees

No one assigned

    Labels

    webkit bugBugs that originate upstream in Apple's WebKit implementation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions