Skip to content

Conversation

@jhhtaylor
Copy link

Summary

This PR attempts to fix audio/video preview for files opened via Safari's "Open Files..." dialog on vscode.dev.

  • Add handling for untitled: scheme in audioPreview.ts and videoPreview.ts
  • Attempt to read file contents and create data URLs for playback
  • Update CSP to allow data: URIs for media-src

Limitation

This fix cannot fully resolve the issue because workspace.fs.readFile() cannot access untitled: scheme files.

When files are opened via Safari's limited File API (browsers without full File System Access API support):

  1. Contents are read via FileReader into memory
  2. A URI with untitled: scheme is created
  3. Custom editors only receive the URI, not the contents
  4. The file system cannot resolve untitled: URIs

Root Cause (needs core fix)

The untitled: scheme is designed for text files, not binary files. A proper fix would require changes in VS Code's core - either:

  • In how Safari's "Open Files..." stores binary file contents (e.g., use blob URLs or temporary files instead of untitled: scheme)
  • Or how custom editors receive untitled document contents

Related Issues

Test Plan

  1. Open vscode.dev in Safari
  2. Use File → Open Files... to open an audio/video file
  3. Observe that the media preview attempts to load (shows player UI) but playback doesn't work due to the limitation above
  4. Compare with Chrome where the full File System Access API is supported

 microsoft#236152)

This PR attempts to fix audio/video preview for files opened via Safari's
"Open Files..." dialog on vscode.dev.

**Changes:**
- Add handling for `untitled:` scheme in audioPreview.ts and videoPreview.ts
- Attempt to read file contents and create data URLs for playback
- Update CSP to allow `data:` URIs for media-src

**Limitation:**
The fix cannot fully work because `workspace.fs.readFile()` cannot access
`untitled:` scheme files. When files are opened via Safari's limited File API:
1. Contents are read via FileReader into memory
2. A URI with `untitled:` scheme is created
3. Custom editors only receive the URI, not the contents
4. The file system cannot resolve `untitled:` URIs

**Root cause (needs core fix):**
The `untitled:` scheme is designed for text files, not binary files. A proper
fix would require changes in VS Code's core - either in how Safari's "Open
Files..." stores binary file contents, or how custom editors receive untitled
document contents.

**Related:** microsoft#148353 (same root cause for other binary files)
@jhhtaylor
Copy link
Author

@microsoft-github-policy-service agree

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