Closed fooevr closed 5 months ago
Same issue. Happens only in debug mode though, release mode works fine.
Same issue. Happens only in debug mode though, release mode works fine.
I've encountered the same issue while using Realm, but didn't face this problem when I switched to Drift. It appears to be related to a pointer error, although I haven't been able to debug it in-depth. As my application is still in the early stages of development, I've successfully transitioned to using Drift.
I have encountered the same issue.
I've tested with both ObjectBox v2.2.1 and v2.3.0.
The kernel panic (I assume) happens only in debug mode. Release mode works fine.
For some reason, it works fine on an iOS 17 simulator. Check the table below for more test outcomes.
iOS | Xcode | Flutter | device type | works | comment |
---|---|---|---|---|---|
16.6.1 | 14.3.1 | 3.13.2 | simulator | ✅ | |
16.6.1 | 14.3.1 | 3.13.2 | physical device | ✅ | |
16.6.1 | 14.3.1 | 3.13.6 | simulator | ✅ | |
16.6.1 | 14.3.1 | 3.13.6 | physical device | ✅ | |
17.0 | 15.0 | 3.13.6 | simulator | ✅ | this one oddly works |
17.0 | 14.3.1 | 3.13.2 | physical device | ❌ | device reboots |
17.0 | 14.3.1 | 3.13.6 | physical device | ❌ | device reboots |
17.0 | 15.0 | 3.13.6 | physical device | ❌ | device reboots |
17.0.1 | 14.3.1 | 3.13.2 | physical device | ❌ | device reboots |
17.0.1 | 14.3.1 | 3.13.6 | physical device | ❌ | device reboots |
17.0.1 | 15.0 | 3.13.6 | physical device | ❌ | device reboots |
17.0.2 | 14.3.1 | 3.13.2 | physical device | ❌ | device reboots |
17.0.2 | 14.3.1 | 3.13.6 | physical device | ❌ | device reboots |
17.0.2 | 15.0 | 3.13.6 | physical device | ❌ | device reboots |
the iOS system will definitely restart.
This sounds like an issue with iOS itself. We still want to find a workaround if possible.
I've encountered the same issue while using Realm
Do we have a bug issue there to share insights?
@techouse Thanks for creating and providing that table. :+1:
The kernel panic (I assume) happens only in debug mode.
I wonder if there's some technical info about that kernel panic that could be provided.
I wonder if there's some technical info about that kernel panic that could be provided.
Since the connection gets terminated it's hard to capture some logs. ☹️
Could be related to this https://developer.apple.com/forums/thread/733642 ?
Could be related to this https://developer.apple.com/forums/thread/733642 ?
Could be, however, only from the description I don't see any changes that should affect ObjectBox.
@techouse Did you/can you try with an older Flutter version, e.g. 3.10? Can you share output of flutter run -v
?
I looked through the current Flutter iOS 17 issues and there are some with apps just terminating (e.g. https://github.com/flutter/flutter/issues/135562), potentially related to native code.
(Also tested our example on macOS 13.5.2 for both Flutter 3.10 and 3.13. TBD on an iOS 17 device. So not ruling out Flutter as the cause, yet.)
@techouse Did you/can you try with an older Flutter version, e.g. 3.10? Can you share output of
flutter run -v
?
I'm not sure Flutter 3.10 can be compiled for iOS 17 in Debug mode as that requires Xcode 15 and to use that you need Flutter 3.13.5.
[✓] Flutter (Channel stable, 3.13.7, on macOS 14.0 23A344 darwin-arm64, locale zh-Hans-US) [✓] Android toolchain - develop for Android devices (Android SDK version 33.0.1) [✓] Xcode - develop for iOS and macOS (Xcode 15.0) [✓] Chrome - develop for the web [✓] Android Studio (version 2022.2) [✓] VS Code (version 1.83.1) [✓] Connected device (3 available) [✓] Network resources
I also encountered this problem. The real machine restarted directly! Whether there is a good solution. Thank you very much!
@techouse @disonwei It would help a lot if we can locate the cause of the crash. I'm not too familiar with debugging iOS crashes, are there any system crash logs or dumps available that one could analyze? As this only occurs in debug mode: can you try to explicitly disconnect Flutter debug tools after launching the app and see if it crashes then?
Edit: helpful infos:
When an iOS device crashes, a crash report is generated in ~/Library/Logs/CrashReporter/MobileDevice.
@greenrobot @greenrobot-team here is the sample of the application that crashes https://github.com/danijel-tolj/objectbox_crash inside the "logs" folder are the logs related to the crash
There is some data that might provide insight into the crash:
In /logs/Runner-2023-10-20-131018.ips
"vmRegionInfo" : "0 is not in any region. Bytes before following region: 4310089728\n REGION TYPE START - END [ VSIZE] PRT\/MAX SHRMOD REGION DETAIL\n UNUSED SPACE AT START\n---> \n __TEXT 100e6c000-100e78000 [ 48K] r-x\/r-x SM=COW ...er.app\/Runner",
"exception" : {"codes":"0x0000000000000001, 0x0000000000000000","rawCodes":[1,0],"type":"EXC_BAD_ACCESS","signal":"SIGSEGV","subtype":"KERN_INVALID_ADDRESS at 0x0000000000000000"},
"termination" : {"flags":0,"code":11,"namespace":"SIGNAL","indicator":"Segmentation fault: 11","byProc":"exc handler","byPid":393},
"vmregioninfo" : "0 is not in any region. Bytes before following region: 4310089728\n REGION TYPE START - END [ VSIZE] PRT\/MAX SHRMOD REGION DETAIL\n UNUSED SPACE AT START\n---> \n __TEXT 100e6c000-100e78000 [ 48K] r-x\/r-x SM=COW ...er.app\/Runner",
"faultingThread" : 0
The crash is always reproducible on any iOS 17 physical device in debug mode only
@danijel-tolj Thanks! Can you provide the crash report file? I've also added more details on how to obtain them in my previous comment. That should contain a trace (e.g. similar to Flutter issues) which should hopefully allow to pinpoint the issue.
Sorry, never mind. I saw you included the full IPS file in your repo.
Opened with Console to get the full report:
It appears the ObjectBox pod (which objectbox_flutter_libs uses) did contain Mac\OBXCodeGen.framework\Versions\A\Resources\Sourcery.app\Contents\Frameworks\libswiftCore.dylib
in 1.8.1, but does not longer in 1.9.0. I'm not sure yet why this file from the code generator would be used by the app at runtime.
~A temporary fix would likely then be to downgrade ObjectBox to 2.2.1, which still uses the 1.8.1
pod.~ Edit: previous comment said using 2.2.1 does not work.
@greenrobot-team Nope, doesn't work, I receive the same error with the same logs. Here's the Jetsam log https://pastebin.com/zRXwGNuf
This appears to be https://github.com/flutter/flutter/issues/67624. @danijel-tolj do you (re)launch the app from the home screen instead of via flutter run?
For us, see https://github.com/flutter/flutter/issues/67624#issuecomment-801971172. During inspecting the plugin code I also noticed that the template for plugin registration has changed. Maybe changing to it already fixes this, will need to have a look.
@greenrobot-team No, I do not open it from the home screen. As soon as the query.find is used after the flutter run command builds the app, it restarts the device immediately
As soon as the query.find is used after the flutter run command builds the app, it restarts the device immediately
Same here. The app works fine on a physical device running iOS 17 in debug mode until I open a screen that queries objectbox.
This appears to be flutter/flutter#67624. @danijel-tolj do you (re)launch the app from the home screen instead of via flutter run?
For us, see flutter/flutter#67624 (comment). During inspecting the plugin code I also noticed that the template for plugin registration has changed. Maybe changing to it already fixes this, will need to have a look.
@greenrobot-team I don't think this will fix it since the insert/put/delete into the database works, so that means the plugin is properly registered, but the query.find seems to access a non existing address, or an address that has been restricted in iOS 17, and it causes the kernel panic
@danijel-tolj That's odd since that is exactly what the crash log you have added to the repo points at. Quoting the relevant part here:
Termination Reason: SIGNAL 11 Segmentation fault: 11
Terminating Process: exc handler [393]
Triggered by Thread: 0
Thread 0 name: Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0 libswiftCore.dylib 0x1a63f43ec swift_getObjectType + 40
1 objectbox_flutter_libs 0x100ff80cc static SwiftObjectboxFlutterLibsPlugin.register(with:) + 108
2 objectbox_flutter_libs 0x100ff82c8 @objc static SwiftObjectboxFlutterLibsPlugin.register(with:) + 56
3 objectbox_flutter_libs 0x100ff8048 +[ObjectboxFlutterLibsPlugin registerWithRegistrar:] + 72
4 Runner 0x100e70070 +[GeneratedPluginRegistrant registerWithRegistry:] + 112
I just published the pre-release 2.3.2-dev.0
which drops the unused method channel registration. To use it, you need to manually edit your pubspec file to use this as the minimum version, e.g.:
dependencies:
objectbox: ^2.3.2-dev.0
If it still crashes, please obtain the crash report, open it with Console and attach the output here.
@greenrobot-team Weirdly, phone still crashes with the updated dependencies
@greenrobot-team Well, this is interesting. I wanted to if there's some issues with the Dart SDK itself, so I downgraded to 3.0.6, and it works perfectly fine! Even with the objectbox 2.3.1, it works properly, so this may indicate to a deeper problem in recent Dart SDK versions
@danijel-tolj Thanks so much for testing!
The crash you get now is https://github.com/flutter/flutter/issues/67624#issuecomment-740219823 again, but for the path_provider_foundation
package. Quoting the crash log and how it again ends at register(with:)
and swift_getObjectType + 40
:
Thread 0 Crashed:
0 libswiftCore.dylib 0x1905783ec swift_getObjectType + 40
1 path_provider_foundation 0x102a4a748 static PathProviderPlugin.register(with:) + 88
2 path_provider_foundation 0x102a4a854 @objc static PathProviderPlugin.register(with:) + 56
I still don't understand what has changed in recent Flutter versions that makes apps crash even when not opening them manually.
@techouse Do you get the same crash log?
@greenrobot-team the last log that can provide some insight is from the ExcUserFault_diagnosticd log which points out that the error is a EXC_GUARD exception which sounds like swift_getObjectType is crashing because it violates guarded resource protection
Looks like the Dart team are on it https://github.com/dart-lang/sdk/issues/53859
Flutter 3.16.0 is out, which fixes this issues on the stable channel
@danijel-tolj Thanks for letting us know! It appears so, but it's not mentioned in the release notes as far as I can see.
Anyways, closing this then. If you are affected, make sure to update to Dart 3.2 (included with Flutter 3.16).
For completion: with 2.4.0
also released the unrelated fix for debug mode crashes on iOS mentioned in my previous comment.
Write a very simple code, when
query.find()
line excuted, the iOS system will definitely restart.Basic info:
dependencies:
flutter doctor