question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Callback must be registered?

See original GitHub issue

If I don’t register any callback, the app will crash on download start with this (same with IOS)

I/flutter ( 5251): Fatal: could not find callback
D/HostConnection( 5251): HostConnection::get() New Host Connection established 0x7b0d1d8e03d0, tid 5368
D/HostConnection( 5251): HostComposition ext ANDROID_EMU_CHECKSUM_HELPER_v1 ANDROID_EMU_native_sync_v2 ANDROID_EMU_native_sync_v3 ANDROID_EMU_native_sync_v4 ANDROID_EMU_dma_v1 ANDROID_EMU_direct_mem ANDROID_EMU_host_composition_v1 ANDROID_EMU_host_composition_v2 ANDROID_EMU_YUV_Cache ANDROID_EMU_async_unmap_buffer GL_OES_EGL_image_external_essl3 GL_OES_vertex_array_object GL_KHR_texture_compression_astc_ldr ANDROID_EMU_host_side_tracing ANDROID_EMU_async_frame_commands ANDROID_EMU_gles_max_version_3_0 
F/libc    ( 5251): FORTIFY: pthread_mutex_lock called on a destroyed mutex (0x7b0c32e178a0)
F/libc    ( 5251): Fatal signal 6 (SIGABRT), code -1 (SI_QUEUE) in tid 5309 (1.ui), pid 5251 (asa.workapp.dev)
*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
Build fingerprint: 'google/sdk_gphone_x86_64_arm64/generic_x86_64_arm64:11/RSR1.201211.001.A1/7054069:userdebug/dev-keys'
Revision: '0'
ABI: 'x86_64'
Timestamp: 2021-04-15 19:37:32+0700
pid: 5251, tid: 5309, name: 1.ui  >>> com.saritasa.workapp.dev <<<
uid: 10153
signal 6 (SIGABRT), code -1 (SI_QUEUE), fault addr --------
Abort message: 'FORTIFY: pthread_mutex_lock called on a destroyed mutex (0x7b0c32e178a0)'
    rax 0000000000000000  rbx 0000000000001483  rcx 00007b0f1dea42a8  rdx 0000000000000006
    r8  0000000000000000  r9  0000000000000000  r10 00007b0c30c0a540  r11 0000000000000246
    r12 0000000000000000  r13 0000000000000018  r14 00007b0c30c0a538  r15 00000000000014bd
    rdi 0000000000001483  rsi 00000000000014bd
    rbp 00007b0d7d8c0428  rsp 00007b0c30c0a528  rip 00007b0f1dea42a8
Lost connection to device.

But if I do something like this, everything works fine.

FlutterDownloader.registerCallback(TestClass.callback);
class TestClass{
     static void callback(String id, DownloadTaskStatus status, int progress) {}
}

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:18
  • Comments:11

github_iconTop GitHub Comments

5reactions
irfan-429commented, Aug 4, 2021

If I don’t register any callback, the app will crash on download start with this (same with IOS)

I/flutter ( 5251): Fatal: could not find callback
D/HostConnection( 5251): HostConnection::get() New Host Connection established 0x7b0d1d8e03d0, tid 5368
D/HostConnection( 5251): HostComposition ext ANDROID_EMU_CHECKSUM_HELPER_v1 ANDROID_EMU_native_sync_v2 ANDROID_EMU_native_sync_v3 ANDROID_EMU_native_sync_v4 ANDROID_EMU_dma_v1 ANDROID_EMU_direct_mem ANDROID_EMU_host_composition_v1 ANDROID_EMU_host_composition_v2 ANDROID_EMU_YUV_Cache ANDROID_EMU_async_unmap_buffer GL_OES_EGL_image_external_essl3 GL_OES_vertex_array_object GL_KHR_texture_compression_astc_ldr ANDROID_EMU_host_side_tracing ANDROID_EMU_async_frame_commands ANDROID_EMU_gles_max_version_3_0 
F/libc    ( 5251): FORTIFY: pthread_mutex_lock called on a destroyed mutex (0x7b0c32e178a0)
F/libc    ( 5251): Fatal signal 6 (SIGABRT), code -1 (SI_QUEUE) in tid 5309 (1.ui), pid 5251 (asa.workapp.dev)
*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
Build fingerprint: 'google/sdk_gphone_x86_64_arm64/generic_x86_64_arm64:11/RSR1.201211.001.A1/7054069:userdebug/dev-keys'
Revision: '0'
ABI: 'x86_64'
Timestamp: 2021-04-15 19:37:32+0700
pid: 5251, tid: 5309, name: 1.ui  >>> com.saritasa.workapp.dev <<<
uid: 10153
signal 6 (SIGABRT), code -1 (SI_QUEUE), fault addr --------
Abort message: 'FORTIFY: pthread_mutex_lock called on a destroyed mutex (0x7b0c32e178a0)'
    rax 0000000000000000  rbx 0000000000001483  rcx 00007b0f1dea42a8  rdx 0000000000000006
    r8  0000000000000000  r9  0000000000000000  r10 00007b0c30c0a540  r11 0000000000000246
    r12 0000000000000000  r13 0000000000000018  r14 00007b0c30c0a538  r15 00000000000014bd
    rdi 0000000000001483  rsi 00000000000014bd
    rbp 00007b0d7d8c0428  rsp 00007b0c30c0a528  rip 00007b0f1dea42a8
Lost connection to device.

But if I do something like this, everything works fine.

FlutterDownloader.registerCallback(TestClass.callback);
class TestClass{
     static void callback(String id, DownloadTaskStatus status, int progress) {}
}

This worked for me.

4reactions
chirag9710commented, Jul 14, 2022

UI is rendered on the main isolate, while download events come from the background isolate (in other words, code in the callback is run in the background isolate), so you have to handle the communication between two isolates

You can do like this

@pragma('vm:entry-point')
static void downloadCallback(
  String id,
  DownloadTaskStatus status,
  int progress,
) {
  print(
    'Callback on background isolate: '
    'task ($id) is in status ($status) and process ($progress)',
  );

  IsolateNameServer.lookupPortByName('downloader_send_port')
      ?.send([id, status, progress]);
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

Register a callback - IBM
For a callback to execute when its associated event occurs, you must register it with the mi_register_callback() function. When you register a callback,...
Read more >
what do you mean by registering a callback function in C?
Registering a callback function simply means that you are arranging for an external entity to call your function. It might happen at a...
Read more >
Registering a Callback - Win32 apps | Microsoft Learn
To register a callback function for the service object to invoke, use the IUPnPService::AddCallback method. This method can be used to register ......
Read more >
Registering an object method as callback - Yoctopuce
To register a callback on a method, we must therefore pass one more information: the reference of the object of the method. Depending...
Read more >
7 Callback Registration - OpenGL
Callbacks for input events should be delivered to the window the event occurs in. Events should not propagate to parent windows. X Implementation...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found