Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fatal Exception: NSInternalInconsistencyException and terminated the app #282

Closed
michaelnabil230 opened this issue Sep 30, 2024 · 9 comments

Comments

@michaelnabil230
Copy link

I'm experiencing a crash when using the flutter_foreground_task package on iOS. The crash appears in Firebase console logs with the following exception:

Fatal Exception: NSInternalInconsistencyException
0  CoreFoundation                 0x8408c (Missing UUID 47427277ee153c17ad686886b0380b5e)
1  libobjc.A.dylib                0x172e4 objc_exception_throw
2  Foundation                     0x82215c (Missing UUID 12e17a7ab65f35ee82d7cbc31004e223)
3  Flutter                        0x15868 (Missing UUID 4c4c440955553144a19ab64ea953a1e7)
4  Flutter                        0x5d3f54 (Missing UUID 4c4c440955553144a19ab64ea953a1e7)
5  Flutter                        0x5d4c54 (Missing UUID 4c4c440955553144a19ab64ea953a1e7)
6  Flutter                        0x5d6a84 (Missing UUID 4c4c440955553144a19ab64ea953a1e7)
7  camera_avfoundation            0xed54 (Missing UUID 3417230753e03b00bf4a1ebfc4221e43)
8  camera_avfoundation            0x4300 (Missing UUID 3417230753e03b00bf4a1ebfc4221e43)
9  Runner                         0x8048 +[GeneratedPluginRegistrant registerWithRegistry:] + 126 (GeneratedPluginRegistrant.m:126)
10 flutter_foreground_task        0x58d8 (Missing UUID 82508b60813e3cdfae96a7e028c63eb2)
11 flutter_foreground_task        0x50f8 (Missing UUID 82508b60813e3cdfae96a7e028c63eb2)
12 flutter_foreground_task        0x4784 (Missing UUID 82508b60813e3cdfae96a7e028c63eb2)
13 flutter_foreground_task        0x6f50 (Missing UUID 82508b60813e3cdfae96a7e028c63eb2)
14 flutter_foreground_task        0xbd38 (Missing UUID 82508b60813e3cdfae96a7e028c63eb2)
15 flutter_foreground_task        0xe098 (Missing UUID 82508b60813e3cdfae96a7e028c63eb2)
16 flutter_foreground_task        0x5238 (Missing UUID 82508b60813e3cdfae96a7e028c63eb2)
17 Flutter                        0x5d4b50 (Missing UUID 4c4c440955553144a19ab64ea953a1e7)
18 Flutter                        0x5f2e8 (Missing UUID 4c4c440955553144a19ab64ea953a1e7)
19 libdispatch.dylib              0x2370 _dispatch_call_block_and_release
20 libdispatch.dylib              0x40d0 _dispatch_client_callout
21 libdispatch.dylib              0x129e0 _dispatch_main_queue_drain
22 libdispatch.dylib              0x125fc _dispatch_main_queue_callback_4CF
23 CoreFoundation                 0x56f64 (Missing UUID 47427277ee153c17ad686886b0380b5e)
24 CoreFoundation                 0x54188 (Missing UUID 47427277ee153c17ad686886b0380b5e)
25 CoreFoundation                 0x535b8 (Missing UUID 47427277ee153c17ad686886b0380b5e)
26 GraphicsServices               0x11c4 GSEventRunModal
27 UIKitCore                      0x3de5f0 (Missing UUID 5bd027b10ec935fdb9f06288a525693a)
28 UIKitCore                      0x48d10c (Missing UUID 5bd027b10ec935fdb9f06288a525693a)
29 UIKitCore                      0x7b9e50 (Missing UUID 5bd027b10ec935fdb9f06288a525693a)
30 Runner                         0x8c20 main (AppDelegate.swift)
31 ???                            0x1a918fd34 (Missing)

The issue seems to be related to the generated plugin registrant or flutter_foreground_task, and it's causing a crash during the app's lifecycle.

Steps to Reproduce:

  1. Implement the flutter_foreground_task in a Flutter project.
  2. Run the app on an iOS device.
  3. The crash occurs, as reported by Firebase.

Expected Behavior:

The app should run without crashing.

Actual Behavior:

The app crashes with the NSInternalInconsistencyException. And the app is terminated and close.

Additional Information:

  • Flutter version: 3.24.3
  • iOS version: 18.0.0
  • flutter_foreground_task version: 8.10.0

The threads if u want
Screenshot 2024-09-30 at 2 42 26 PM
Screenshot 2024-09-30 at 2 42 04 PM
Screenshot 2024-09-30 at 2 42 13 PM
Screenshot 2024-09-30 at 2 42 21 PM

Please let me know if you need more information or if there are any workarounds for this issue. Thanks for your help!

@michaelnabil230 michaelnabil230 changed the title Fatal Exception: NSInternalInconsistencyException when using flutter_foreground_task Fatal Exception: NSInternalInconsistencyException and terminated the app Sep 30, 2024
@michaelnabil230
Copy link
Author

Additional Information:

I tested the package with different versions, and here are the results:

  • Version 8.9.0: Works fine without any issues.
  • Version 8.10.0: Causes the crash and terminates the app.

It seems the issue was introduced in version 8.10.0.


This additional information can help the contributors identify the source of the problem between the two versions.

@Dev-hwang
Copy link
Owner

@michaelnabil230

Sorry for the late reply.

I'll check it out on iOS 18 version.

@michaelnabil230
Copy link
Author

Take your time ✌🏻

@Dev-hwang
Copy link
Owner

@michaelnabil230

Version 8.10.2 has been published.

Please check and let me know if there are any problems.

@michaelnabil230
Copy link
Author

@Dev-hwang

I just tested the app and found a major bug. The app is running twice in the background, for ex: causing the API to be called twice simultaneously.

@Dev-hwang
Copy link
Owner

Dev-hwang commented Oct 3, 2024

@michaelnabil230

It seems to work fine in the example(counter, location, record, internal_plugin etc)...

Are you using service APIs in your app lifecycle?

I would appreciate it if you could tell me what plugins you use and test scenarios.

It would be more helpful if you could provide a sample project to reproduce the problem.

@michaelnabil230
Copy link
Author

Hi @Dev-hwang,

I have created an app to demonstrate the issue. You can test it by checking out the repository here: GitHub Repo.

In the app, if you use flutter_foreground_task: ^8.10.2, you will see that the API calls are printed twice in the console log. However, when downgrading to flutter_foreground_task: 8.9.0, the app works as expected and the API call is executed only once.

@Dev-hwang
Copy link
Owner

@michaelnabil230

Version 8.10.4 has been published.

8.10.4

  • [FIX] Fixed an issue where main function was called repeatedly when there was no callback to start
  • [FIX] Handle exceptions that occur when service component cannot be found

This issue seems to have occurred in version 8.10.2.

I think this issue was a fatal error for users who did not implement TaskHandler.

Thank you for reporting the issue 😁

@michaelnabil230
Copy link
Author

Hello @Dev-hwang,

I have tested this version, and it is stable at the moment. If any issues arise, I can open a new issue.

Thanks ❤️🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants