Skip to content

Commit ce6dd85

Browse files
committed
Bugfix for LoadImageAtPathAsync and GetVideoThumbnailAsync
1 parent fd8dcbb commit ce6dd85

3 files changed

Lines changed: 10 additions & 6 deletions

File tree

Plugins/NativeCamera/NativeCamera.cs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -361,9 +361,11 @@ public static async Task<Texture2D> LoadImageAtPathAsync( string imagePath, int
361361
maxSize = SystemInfo.maxTextureSize;
362362

363363
#if !UNITY_EDITOR && UNITY_ANDROID
364-
string loadPath = await TryCallNativeAndroidFunctionOnSeparateThread( () => AJC.CallStatic<string>( "LoadImageAtPath", Context, imagePath, TemporaryImagePath, maxSize ) );
364+
string temporaryImagePath = TemporaryImagePath; // Must be accessed from main thread
365+
string loadPath = await TryCallNativeAndroidFunctionOnSeparateThread( () => AJC.CallStatic<string>( "LoadImageAtPath", Context, imagePath, temporaryImagePath, maxSize ) );
365366
#elif !UNITY_EDITOR && UNITY_IOS
366-
string loadPath = await Task.Run( () => _NativeCamera_LoadImageAtPath( imagePath, TemporaryImagePath, maxSize ) );
367+
string temporaryImagePath = TemporaryImagePath; // Must be accessed from main thread
368+
string loadPath = await Task.Run( () => _NativeCamera_LoadImageAtPath( imagePath, temporaryImagePath, maxSize ) );
367369
#else
368370
string loadPath = imagePath;
369371
#endif
@@ -496,9 +498,11 @@ public static async Task<Texture2D> GetVideoThumbnailAsync( string videoPath, in
496498
maxSize = SystemInfo.maxTextureSize;
497499

498500
#if !UNITY_EDITOR && UNITY_ANDROID
499-
string thumbnailPath = await TryCallNativeAndroidFunctionOnSeparateThread( () => AJC.CallStatic<string>( "GetVideoThumbnail", Context, videoPath, TemporaryImagePath + ".png", false, maxSize, captureTimeInSeconds ) );
501+
string temporaryImagePath = TemporaryImagePath; // Must be accessed from main thread
502+
string thumbnailPath = await TryCallNativeAndroidFunctionOnSeparateThread( () => AJC.CallStatic<string>( "GetVideoThumbnail", Context, videoPath, temporaryImagePath + ".png", false, maxSize, captureTimeInSeconds ) );
500503
#elif !UNITY_EDITOR && UNITY_IOS
501-
string thumbnailPath = await Task.Run( () => _NativeCamera_GetVideoThumbnail( videoPath, TemporaryImagePath + ".png", maxSize, captureTimeInSeconds ) );
504+
string temporaryImagePath = TemporaryImagePath; // Must be accessed from main thread
505+
string thumbnailPath = await Task.Run( () => _NativeCamera_GetVideoThumbnail( videoPath, temporaryImagePath + ".png", maxSize, captureTimeInSeconds ) );
502506
#else
503507
string thumbnailPath = null;
504508
#endif

Plugins/NativeCamera/README.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
= Native Camera for Android & iOS (v1.3.7) =
1+
= Native Camera for Android & iOS (v1.3.8) =
22

33
Online documentation & example code available at: https://github.com/yasirkula/UnityNativeCamera
44
E-mail: yasirkula@gmail.com

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "com.yasirkula.nativecamera",
33
"displayName": "Native Camera",
4-
"version": "1.3.7",
4+
"version": "1.3.8",
55
"documentationUrl": "https://github.com/yasirkula/UnityNativeCamera",
66
"changelogUrl": "https://github.com/yasirkula/UnityNativeCamera/releases",
77
"licensesUrl": "https://github.com/yasirkula/UnityNativeCamera/blob/master/LICENSE.txt",

0 commit comments

Comments
 (0)