JimmyDaddy / react-native-image-marker

🙈Adding text or icon watermark to your image using React Native👀👀
https://jimmydaddy.github.io/react-native-image-marker/
MIT License
325 stars 94 forks source link

App crash on markText using iOS #105

Closed radkra closed 1 year ago

radkra commented 1 year ago

Describe the bug IOS application crashes while I'm trying to use markText functionality (markImages works like a charm tho). I'm pasting below the code which makes the crash. I was checking similar threads in issues, but cannot see what I'm doing wrong.

Exception Type:  EXC_BAD_ACCESS (SIGSEGV)
Exception Subtype: UNKNOWN_0xD at 0x0000000000000000
Exception Codes: 0x000000000000000d, 0x0000000000000000

To Reproduce Steps to reproduce the behavior:

 ImageMarker.markText({
      src: storyBase,
      text: 'text',
      saveFormat: ImageFormat.png,
      color: '#FFFFFF',
      fontName: 'Arial-Regular',
      fontSize: 12,
      X: 0,
      Y: 0,
      shadowStyle: null,
      textBackgroundStyle: null,
      scale: 1, 
      quality: 100, 
    })
      .then(path => {
        console.log('path' + path);
      })
      .catch(error => {
        console.log('error', error);
      });

Devlopment environment(please complete the following information):

LaGregance commented 1 year ago

Same problem for me, in the xcode console I get:

2023-07-11 14:20:38.166826+0200 MyApp[420:14060] [native] Exception '*** -[__NSPlaceholderDictionary initWithObjects:forKeys:count:]: attempt to insert nil object from objects[2]' was thrown while invoking addTextByPosition on target ImageMarker with params (
        {
        color = red;
        fontName = Poppins;
        fontSize = 18;
        maxSize = 2048;
        position = bottomRight;
        quality = 100;
        saveFormat = jpg;
        scale = 1;
        src =         {
            "__packager_asset" = 0;
            uri = "/var/mobile/Containers/Data/Application/BDD3F61B-1169-4468-90BD-F65D1527359E/tmp/DB60F0B8-E835-4456-B760-D2E6BF198D8E.jpg";
        };
        text = "11/07/2023 14:20 iPad Mini 5";
    },
    18032,
    18033
)
callstack: (
    0   CoreFoundation                      0x00000001ad7f2178 9624AAFD-5437-3772-A507-0F357875808D + 1253752
    1   libobjc.A.dylib                     0x00000001ad506c1c objc_exception_throw + 60
    2   CoreFoundation                      0x00000001ad84b3a8 9624AAFD-5437-3772-A507-0F357875808D + 1618856
    3   CoreFoundation                      0x00000001ad855320 9624AAFD-5437-3772-A507-0F357875808D + 1659680
    4   CoreFoundation                      0x00000001ad6d8fd0 9624AAFD-5437-3772-A507-0F357875808D + 102352
    5   CoreFoundation                      0x00000001ad6ca80c 9624AAFD-5437-3772-A507-0F357875808D + 43020
    6   MyApp                      0x0000000102ea221c markerImgWithTextByPosition + 316
    7   MyApp                      0x0000000102ea318c __51-[ImageMarker addTextByPosition:resolver:rejecter:]_block_invoke + 284
    8   MyApp                      0x0000000102a9b1d4 __128-[RCTImageLoader loadImageWithURLRequest:size:scale:clipped:resizeMode:priority:progressBlock:partialLoadBlock:completionBlock:]_block_invoke + 104
    9   MyApp                      0x0000000102aa05c8 __140-[RCTImageLoader loadImageWithURLRequest:size:scale:clipped:resizeMode:priority:attribution:progressBlock:partialLoadBlock:completionBlock:]_block_invoke_2 + 404
    10  MyApp                      0x0000000102a9d3f8 __139-[RCTImageLoader _loadImageOrDataWithURLRequest:size:scale:resizeMode:priority:attribution:progressBlock:partialLoadBlock:completionBlock:]_block_invoke + 916
    11  MyApp                      0x0000000102a9dbe4 __139-[RCTImageLoader _loadImageOrDataWithURLRequest:size:scale:resizeMode:priority:attribution:progressBlock:partialLoadBlock:completionBlock:]_block_invoke_2.168 + 100
    12  MyApp                      0x0000000102ab3a5c -[RCTLocalAssetImageLoader loadImageForURL:size:scale:resizeMode:progressHandler:partialLoadHandler:completionHandler:] + 284
    13  MyApp                      0x0000000102a9c7e0 -[RCTImageLoader _loadImageOrDataWithURLRequest:size:scale:resizeMode:priority:attribution:progressBlock:partialLoadBlock:completionBlock:] + 3256
    14  MyApp                      0x0000000102a9ffec -[RCTImageLoader loadImageWithURLRequest:size:scale:clipped:resizeMode:priority:attribution:progressBlock:partialLoadBlock:completionBlock:] + 768
    15  MyApp                      0x0000000102a9afe8 -[RCTImageLoader loadImageWithURLRequest:size:scale:clipped:resizeMode:priority:progressBlock:partialLoadBlock:completionBlock:] + 436
    16  MyApp                      0x0000000102a9ac34 -[RCTImageLoader loadImageWithURLRequest:priority:callback:] + 160
    17  MyApp                      0x0000000102a9ab1c -[RCTImageLoader loadImageWithURLRequest:callback:] + 84
    18  MyApp                      0x0000000102ea2fe4 -[ImageMarker addTextByPosition:resolver:rejecter:] + 412
    19  CoreFoundation                      0x00000001ad7f8d14 9624AAFD-5437-3772-A507-0F357875808D + 1281300
    20  CoreFoundation                      0x00000001ad6c1de8 9624AAFD-5437-3772-A507-0F357875808D + 7656
    21  CoreFoundation                      0x00000001ad6c2a10 9624AAFD-5437-3772-A507-0F357875808D + 10768
    22  MyApp                      0x00000001029addbc -[RCTModuleMethod invokeWithBridge:module:arguments:] + 1808
    23  MyApp                      0x00000001029b1cbc _ZN8facebook5reactL11invokeInnerEP9RCTBridgeP13RCTModuleDatajRKN5folly7dynamicEiN12_GLOBAL__N_117SchedulingContextE + 1596
    24  MyApp                      0x00000001029b14b4 _ZZN8facebook5react15RCTNativeModule6invokeEjON5folly7dynamicEiENK3$_0clEv + 128
    25  MyApp                      0x00000001029b1428 ___ZN8facebook5react15RCTNativeModule6invokeEjON5folly7dynamicEi_block_invoke + 28
    26  libdispatch.dylib                   0x0000000124ee5d10 _dispatch_call_block_and_release + 32
    27  libdispatch.dylib                   0x0000000124ee718c _dispatch_client_callout + 20
    28  libdispatch.dylib                   0x0000000124eee968 _dispatch_lane_serial_drain + 724
    29  libdispatch.dylib                   0x0000000124eef580 _dispatch_lane_invoke + 440
    30  libdispatch.dylib                   0x0000000124efb0f0 _dispatch_workloop_worker_thread + 1344
    31  libsystem_pthread.dylib             0x00000001ad4f9714 _pthread_wqthread + 276
    32  libsystem_pthread.dylib             0x00000001ad4ff9c8 start_wqthread + 8
)

Using the code:

await ImageMarker.markText({
    src,
    text: '11/07/2023 14:20 iPad Mini 5',
    position: Position.bottomRight,
    color: '#FF0000',
    fontSize: 18,
    fontName: 'Poppins',
    scale: 1,
    quality: 100,
    saveFormat: ImageFormat.jpg,
  });
JimmyDaddy commented 1 year ago

fixed it on latest version: 0.9.2, pls update it @LaGregance @radkra

LaGregance commented 1 year ago

Thanks, you are the best !