kfiross / flutter_mongodb_realm

Unofficial Flutter plugin for using MongoDB Realm services on Android, iOS and web.
Apache License 2.0
41 stars 17 forks source link

App crashing in release mode #8

Closed revabu closed 1 year ago

revabu commented 4 years ago

Thanks for working on this project, it's mostly worked for me so far. However, though my app works fine in debug mode, it is crashing when executing some mongodb functions in release mode.

I was able to narrow it down to a few things in my app causing the crash and was able to reproduce it in a new flutter app. Initialization and authentication works fine. Calling a stitch function or accessing database with find or findOne (haven't tried any other functionalities since I don't use them) would immediately crash though.

I also tried with different databases and collections just to be sure, same result. Running flutter run --release --verbose also didn't turn up anything interesting in logs since building, installing and launching on my device worked without issues.

So just wanted to check if this is an issue that you are able to reproduce on your end?

revabu commented 4 years ago

Also, if it helps, I've only tested on 2 iOS devices and haven't tested on Android yet. (Will try that soon)

And here are the results of my flutter doctor:

[✓] Flutter (Channel stable, v1.17.3, on Mac OS X 10.15.5 19F101, locale en-US)

[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3) [✓] Xcode - develop for iOS and macOS (Xcode 11.5) [✓] Android Studio (version 4.0) [✓] Connected device (1 available)

• No issues found!

kfiross commented 4 years ago

Hi, Thanks for the feedback! I'll try to figure it soon

kfiross commented 4 years ago

Unfortunately, I can't check because I don't own a real device.. If you will have a clue, I'll really appreciate your help

revabu commented 4 years ago

I was able to test my app on Android and it worked fine there, so it looks like it only impacts iOS in release mode. I'll be trying a few things in xcode to see if that changes anything. Let me know if you have any suggestions as I'm not exactly the greatest expert in xcode haha.

revabu commented 4 years ago

Not sure if this is related to my app crashing issue, but when I set xcode build to release (no real device needed, I used iOS emulator), I do get an error. On the other hand, it worked without a problem when in debug mode.

image

image

revabu commented 4 years ago

Hi, just want to check if there's any headway on this or if you were able to reproduce the issue? Trying to figure out if this is a problem with my specific setup or if it affects all iOS apps in release mode.

Thanks!

revabu commented 4 years ago

Hello! Do you have a rough timeline of when you are able to investigate/fix this issue? Hoping to use this plugin for a project but need to estimate if I'm able to wait for fix or need to look for alternative workaround.

Thank you!

kfiross commented 4 years ago

Hi, I hope to fix it in the coming 2 weeks

revabu commented 4 years ago

Thanks for the heads up!

revabu commented 4 years ago

Hi there! I noticed the new 0.8.0+2 version update and was wondering if it was meant to fix the issue above in release mode?

Unfortunately, the old issues still persist for me. After successful build in release mode, app opens up with no problem and only crashes when it attempts to call a stitch function or fetch data from db.

However, I did find a potential clue in my sentry logs, apparently I get Failed to find documents: internalError(message: "could not encode document as extended JSON string"): encodingError in release mode when attempting to fetch some data from db, which doesn't occur in debug mode.

Thanks for looking into this.

kfiross commented 4 years ago

Hi, thanks for the support! Actually I updated some bug caused by web integration. So If understand, the app crashed on ios released mode in some circumstances.

Unfortunately I don't own a real device to fix released mode related bugs with ios version. :/ So if you can figure this out somehow, I'll really appreciate to make PR.

andresherrera12 commented 3 years ago

@revabu Hi, did you find a solution for this issue? I'm getting the same error when running on release mode. Only in iOS

"could not encode document as extended JSON string"

kclee1994 commented 3 years ago

Hi, I am facing the same issue. Seems like the problem is from constructing the request body for findOne(). I get the same error "could not encode document... ". After some searching around, i found that it is thrown in this class StitchDocRequestBuilder when calling build (which is building the rq body)

Tested on android release, no problem. It only happens on iOS testflight. iOS simulator no problem as well.

Could it be due to "document.canonicalExtendedJSON", where it returns "" when it fails to encode.

Would appreciate if this can be fixed soon, want to release the app but stuck on iOS. Thanks!