Mimetis / Dotmim.Sync

A brand new database synchronization framework, multi platform, multi databases, developed on top of .Net Standard 2.0. https://dotmimsync.readthedocs.io/
MIT License
883 stars 191 forks source link

Native crash in Xamarin iOS #641

Closed flacidsnake closed 2 years ago

flacidsnake commented 2 years ago

Hi,

I get a native crash quite often when synchronizing from Xamarin iOS to SQL Server via WebClientOrchestrator.

I'm running Dotmim.Sync.Sqlite and Dotmim.Sync.Web.Client on version 0.9.1. Any idea how to fix this?

Edit: crash details attached as text file

crash.txt

Mimetis commented 2 years ago

your message is barely readable... Please reformat, delete unnecessary lines, make a first handhsake on your logs and filter relevant lines.

From what I see here, you have an issue with SQLITE. Did you see https://docs.microsoft.com/en-us/dotnet/standard/data/sqlite/xamarin#ios ?

flacidsnake commented 2 years ago

Thank you for your answer. I uploaded the crash as a text file.

I tried to initialize the bundle using SQLitePCL.Batteries_V2.Init(); but that doesn't make any difference.. The crash is random, but happens quite often

flacidsnake commented 2 years ago

I noticed the crash occurs the 1st time the application runs in Release mode using a physical device. Then I kill the crashed app and open it again and voilà, it works.

Same code in Debug mode runs fine with a physical device.

Any idea @Mimetis ?

Mimetis commented 2 years ago

Seems the problem is not coming from DMS.

I guess you have a problem on fresh start on your client application. I don't know how I can help you on this.

Will close the issue until you find it's a specific DMS issue

Cuse499 commented 2 years ago

Hi, I'm seeing the same issue synchronizing from Xamarin iOS to SQL Server via WebClientOrchestrator: stacktrace.txt

@flacidsnake did you ever figure this out?

This native crash only happens on my Xamarin.Forms iOS app and causes it to hang during a DMS sync. I can verify that it does not happen in my WPF, Xamarin.Forms Android, or Xamarin.Forms UWP apps (I basically use the same shared code project for performing a DMS sync across all of these platforms).

Based on the use case and stack trace, I suspect this could be a DMS issue related to how it performs syncing on iOS, but unfortunately I don't really know how to dive any deeper into this.

The crash/hang happens randomly, about ~20% of the time. The rest of the time the DMS sync runs without issue and works as expected. I've been using DMS for several months now (big fan of the project) and only recently noticed this issue.

I have reproduced the issue on an iPhone device as well as the ios simulator. I have seen this happen using version 0.9.1 and also when downgrading to 0.7.3.

Any tips/suggestions would be appreciated, thanks.

Mimetis commented 2 years ago

It's hard to debug for me, especially because it's a random issue (random until we found what's wrong) The other thing is that I'm working on a windows machine, and I don't have a Mac / IPhone to be able to debug the solution directly from an IOS device....

If you find anything useful, please share it, or send me a DM

Mimetis commented 2 years ago

Maybe it's related to memory consumption ? Did you make a test with the last version (you can test the pre release of v0.9.4) ?

Cuse499 commented 2 years ago

To answer your question, we have not tried testing the pre-release of 0.9.4. As we mentioned previously, DMS has worked very well for us since we replaced Azure Mobile Sync with DMS almost a year ago. To date, DMS still works very well for our Microsoft apps as well as our Android apps. It was also working well with our iOS apps until we discovered this issue approximately 2 weeks ago. As a result, we reverted to a software release from early December and discovered that the issue still exists so we are trying to figure out when it was introduced.

We are able to reproduce the issue by completing the following steps (based on "non-technical" end user feedback):

1) Install app on either iOS device (e.g. iPhone, etc.) or iOS Simulator (e.g. LambdaTest) using Microsoft AppCenter.

2) Login to app using valid account

3) After successful authentication, we experience an "App Hang" where the app was frozen until the iPhone was physically turned off and subsequently turned back on.

4a) On one iOS device, the subsequent login worked, the app opened, and everything worked fine until data was entered. Then, after an app logout and logon, the "App Hang" returned.

4b) On a second iOS device, we received an "App Hang" every single time until a 401 error appeared.

5) In the case of 4a, we did discover that DMS was able to sync data between the client app and the server before experiencing the "App Hang".

In light of the above, we believe that the issue is isolated specifically to iOS. Furthermore, we have seen isolated use cases where the data sync was successful and the app did not hang. Our issue is that we cannot identify why the "App Hang" exists in the first place nor can we identify what change could have taken place within the past ~2-4 weeks to cause this issue.

Given that security & permissions are managed differently in iOS than Windows & Android, we are exploring whether our issue could be security or permissions-related. However, even this theory isn't necessarily valid since the sync does work in some scenarios.

In closing, I will ask our lead developer to reach out to you with additional information in the morning (we are -05:00 - Eastern Standard time). Any assistance you can provide would be greatly appreciated. Thank you.


From: Sébastien Pertus @.***> Sent: Tuesday, March 8, 2022 3:26 AM To: Mimetis/Dotmim.Sync Cc: George Mazevski; Comment Subject: Re: [Mimetis/Dotmim.Sync] Native crash in Xamarin iOS (Issue #641)

Maybe it's related to memory consumption ? Did you make a test with the last version (you can test the pre release of v0.9.4) ?

— Reply to this email directly, view it on GitHubhttps://github.com/Mimetis/Dotmim.Sync/issues/641#issuecomment-1061525043, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ACCSGHXW4IJ3ZM5GUZOZ5ALU64FKPANCNFSM5IYDXDPQ. Triage notifications on the go with GitHub Mobile for iOShttps://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Androidhttps://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub. You are receiving this because you commented.Message ID: @.***>

Mimetis commented 2 years ago

Any assistance you can provide would be greatly appreciated. Thank you.

Will try :)

Cuse499 commented 2 years ago

Good news! The issue appears resolved in DMS v0.9.4 pre release (0.9.4-beta-0764) testing on an iPhone device and iOS simulator.

I downgraded to 0.9.1 again just to test the same code base and found that the iOS crash/hang reappears again randomly.

Knowing that the issue can happen randomly, I will continue to monitor it and write back if it returns. With that said, I believe upgrading to 0.9.4 pre release was the solution. Thanks!

govdevteam commented 2 years ago

@Mimetis,

Any thoughts on what may have changed between 0.9.1, 0.9.3, and your 0.9.4 beta that could explain this "App Hang" issue? It is still odd that only iOS apps were affected while Windows & Android apps continued to work fine. Any insight would be greatly appreciated. Thank you.

Mimetis commented 2 years ago

v0.9.3 removes memory pressure (see #659) that can causes random crash I guess In v.0.9.4 I also removed unnecessaries references in theDotmim.Sync.Web.Client project. Compare : Before we were using the full AspNetCore reference (Not sure it changes anything, but who knows) https://github.com/Mimetis/Dotmim.Sync/blob/f992c9e11239bd39afa375d3aab6e4410ce16d8d/Projects/Dotmim.Sync.Web.Client/Dotmim.Sync.Web.Client.csproj#L38 And now, we are just using the httpfeatures https://github.com/Mimetis/Dotmim.Sync/blob/546a8fca816760dafcd4f8d248124aa7668f992e/Projects/Dotmim.Sync.Web.Client/Dotmim.Sync.Web.Client.csproj#L38

I guess the problem was the memory pressure. If you can test with v0.9.3 to see if you still have the issue or not ? But once again, I think you need more tests to figure out if this is the cause or not Let me know

flacidsnake commented 2 years ago

Hi @Cuse499 This evil random issue never happened again since I updated to 0.9.4 . Relieving the memory pressure did the trick 🥳

@Mimetis I'm closing this. Will reopen if it happens again :)

Mimetis commented 2 years ago

The MEP thing : Memory Evil Pressure :)