UnityNativeGallery icon indicating copy to clipboard operation
UnityNativeGallery copied to clipboard

IOS 17 - WhatsApp videos

Open Days99 opened this issue 2 years ago • 7 comments

Description of the bug

IOS 17 can't open whats app videos

Reproduction steps

Use native gallery, try to open a video saved from whats app

Platform specs

IOS 17, iPhone 12 Pro

  • Unity version: 2021.3.32f1
  • Platform: IOS
  • Device: iPhone 12 Pro IOS 17
  • How did you download the plugin: Github, latest release

Additional info

When loading a video from whats app, it fails to load

Days99 avatar Nov 14 '23 17:11 Days99

May I see your code and know what you mean by video failing to load? What happens? Are any native errors logged? Could you spot anything about WhatsApp videos that differ them from other videos?

yasirkula avatar Nov 14 '23 19:11 yasirkula

Im just doing it like the example of loading images and videos but the path that returns when I choose a video from whats app is a jpeg image for some reason. There arent any native error just the Texture it returns is null. From what I tried other images and videos from other apps work just whats app doesn't. From my research most apps changed to the embedded photo picker for IOS 17, they have different access options and they could load whats app videos.

Days99 avatar Nov 14 '23 21:11 Days99

I tried doing it but couldn't figure out how to link the NativeGallery.mm file with a swift class

Days99 avatar Nov 14 '23 21:11 Days99

NativeGallery also uses iOS' built-in photo picker PHPickerViewController. It should support even live photos (though only as static images). Here's what I'm understanding so far:

  • You call GetVideoFromGallery
  • You select a video that was created by WhatsApp
  • The returned file ends with extension .jpeg
  • You can't play that .jpeg with VideoPlayer component
  • There are no Textures that come into play during these steps

If any of these steps are different, please let me know.

PS. I don't have Swift experience so I can't help with that issue.

yasirkula avatar Nov 14 '23 21:11 yasirkula

I know Native Gallery uses PHPickerViewController, but Apple has a new way of accessing photo, the PhotosPicker (you can read more about it herehttps://developer.apple.com/videos/play/wwdc2023/10107/. And it seems in the new IOS 17 a lot of apps are now asking a new type of permission to access the gallery that already comes implemented in the new class (they mention it in the videos) and now in the gallery settings of IOS 17 the app appears with limited access instead of full access like other apps. About the steps you are mostly correct but I never try to play the jpeg file as a video I try to load it as an image and it returns a null value on the LoadImageAtPath() function

Days99 avatar Nov 15 '23 01:11 Days99

I shall check it in my spare time and let you know of the results. Thank you for all the information.

yasirkula avatar Nov 16 '23 06:11 yasirkula

From my understanding, this is just PHPickerViewController for SwiftUI, not a completely new photo picker technology.

Could you try changing the following line to config.preferredAssetRepresentationMode = PHPickerConfigurationAssetRepresentationModeCompatible; or PHPickerConfigurationAssetRepresentationModeAutomatic: https://github.com/yasirkula/UnityNativeGallery/blob/b6e0fd9530e403b5ac1bfa3f061d09073e09fd7d/Plugins/NativeGallery/iOS/NativeGallery.mm#L599

If that doesn't work, what happens when you comment out these lines: https://github.com/yasirkula/UnityNativeGallery/blob/b6e0fd9530e403b5ac1bfa3f061d09073e09fd7d/Plugins/NativeGallery/iOS/NativeGallery.mm#L868-L1067

And could you spot useful logs in Xcode's console?

yasirkula avatar Dec 03 '23 14:12 yasirkula