Fix cropImage crash with float displaySize
Summary: On Android, using `ImageEditor.cropImage` with `displaySize` option may causes crash with exception below: ``` FATAL EXCEPTION: mqt_native_modules Process: me.sohobloo.test, PID: 11308 com.facebook.react.bridge.UnexpectedNativeTypeException: TypeError: expected dynamic type `int64', but had type `double' at com.facebook.react.bridge.ReadableNativeMap.getInt(Native Method) at com.facebook.react.modules.camera.ImageEditingManager.cropImage(ImageEditingManager.java:196) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at com.facebook.react.bridge.BaseJavaModule$JavaMethod.invoke(BaseJavaModule.java:345) at com.facebook.react.cxxbridge.JavaModuleWrapper.invoke(JavaModuleWrapper.java:141) at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method) at android.os.Handler.handleCallback(Handler.java:815) at android.os.Handler.dispatchMessage(Handler.java:104) at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:31) at android.os.Looper.loop(Looper.java:194) at com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(MessageQueueThreadImpl.java:196) at java.lang.Thread.run(Thread.java:818) ``` This is caused by getInt from `number` type of JS. ```javascript ImageEditor.cropImage( uri, { offset: {x: 0, y: 0}, size: {width: 320, height: 240}, displaySize: {width: 320.5, height: 240.5} } ); ``` Closes https://github.com/facebook/react-native/pull/13312 Differential Revision: D5462709 Pulled By: shergin fbshipit-source-id: 42cb853b533769b6969b8ac9ad50f3dd3c764055
This commit is contained in:
parent
ed3c018ee4
commit
f32627f890
|
@ -193,7 +193,9 @@ public class ImageEditingManager extends ReactContextBaseJavaModule {
|
|||
error);
|
||||
if (options.hasKey("displaySize")) {
|
||||
ReadableMap targetSize = options.getMap("displaySize");
|
||||
cropTask.setTargetSize(targetSize.getInt("width"), targetSize.getInt("height"));
|
||||
cropTask.setTargetSize(
|
||||
(int) targetSize.getDouble("width"),
|
||||
(int) targetSize.getDouble("height"));
|
||||
}
|
||||
cropTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue