souvik-ghosh / react-native-create-thumbnail

iOS/Android thumbnail generator with support for both local and remote videos
MIT License
252 stars 105 forks source link

Error Domain=NSCocoaErrorDomain Code=257 "The file “FileName.mov” couldn’t be opened because you don’t have permission to view it." #118

Open paulapithon opened 1 week ago

paulapithon commented 1 week ago

Describe the bug There's a crash happening when users doesn't have the appropriate viewing permission on iOS 18.

Error Domain=NSCocoaErrorDomain Code=257 "The file “FileName.mov” couldn’t be opened because you don’t have permission to view it." UserInfo={NSURL=file:///var/mobile/Media/.../FileName.mov#YnBsaXN0MDDRAQJfEBtSZWNvbW1lbmRlZEZvckltbWVyc2l2ZU1vZGUQAAgLKQAAAAAAAAEBAAAAAAAAAAMAAAAAAAAAAAAAAAAAAAAr, AVErrorFailedDependenciesKey=( "assetProperty_AssetType" ), NSUnderlyingError=0x3003d6700 {Error Domain=NSOSStatusErrorDomain Code=-12203 "(null)"}}

node_modules/react-native/React/Base/RCTUtils.m:503 - RCTJSErrorFromCodeMessageAndNSError
node_modules/react-native/React/Base/RCTModuleMethod.mm:370 - __41-[RCTModuleMethod processMethodSignature]_block_invoke_2.55
node_modules/react-native-create-thumbnail/ios/CreateThumbnail.m:75 - __58-[CreateThumbnail create:findEventsWithResolver:rejecter:]_block_invoke.52

To Reproduce Steps to reproduce the behavior:

  1. Remove view photo library permission from app.
  2. Try to generate thumbnail.
  3. App crashes.

Version react-native-create-thumbnail 2.0.0

Expected Results App shouldn't crash, instead promise should be rejected so it will be handled gracefully on the App side.

Snack, code example, screenshot, or link to a repository

import {createThumbnail} from 'react-native-create-thumbnail';
const createdThumbnail = await createThumbnail({
      url: item.url,
});