My Xamarin Forms App is using Realm for direct binding to local storage like this https://www.mongodb.com/developer/languages/csharp/use-effectively-realm-in-xamarin-forms/.
Most of the SF controls work well when binding directly to the Realm objects ( See attached example for reference, binding an SfNumericUpDown or Xamarin's built-in Editor works well), however whent trying to bind the SFRichTextEditor, the App either freezes or just doesn't bind to my properties and no errors are displayed on the console to be able to track the issue.
Realm usually works on the main thread so I'm not sure if this is a threading issue with SFRichTextEditor specifically.
We were able to reproduce the issue with “Freezes the app while binding the SfRichTextEditor to Realm”. In Android platform. Currently, we are validating this issue and we will update the further details on February 15th, 2023.
They provided sample is working properly on iOS Platform. Please find video link below,
Currently, we are validating the issue “Freezes the app while binding the SfRichTextEditor to Realm in Android platform” and we will update the further details on February 17th, 2023.
We were not able to reproduce the reported issue on a simple sample. The issue was only reproduced on the Realm sample. On further analyzation we found some suggestions to initialize and close the realm object in a proper thread. Kindly follow the links below to create the realm objects on the proper thread.
Hi Hemalatha, thanks for checkin this issue.
As you can see on the original example I attached, the Realm is only accessed on the UI thread so that shouldn't be a problem. On the other hand, you can see on the same sample the binding works with native Xamarin controls like Label and Entry and even with the SfNumericUpDown, it's just smething about the SfRichTextEditor which makes it fail when binding to the Realm but I cant figure it out becase there's no errors thrown so maybe you can check on your side what the internal exception incompatibility is about.
is a wrapper of content editable div elements. We were able to reproduce the
reported issue when we use Hybrid Web View in the XForms android platform. We
can replicate the same issue in the “contentEditable” div also,
which has the same behavior as the Rich Text Editor. So, we have raised the
query in Xamarin Discussion and please find the link from below, We will update
further once the Xamarin team provides any update.
the sample to ensure this behavior in the attachment and check the below screenshot illustration of the issue reproducing in the “contentEditable” div
Please find the screenshot without the Realm:
We will update further once the Xamarin team provides any update.
After thinking about it some more, I figured since we're already wrapping SFRichTextEditor with our own control we could force it to access the Realm from the main thread by manually handling the text change event like this:
private void Input_TextChanged(object sender, Syncfusion.XForms.RichTextEditor.TextChangedEventArgs e)
Device.BeginInvokeOnMainThread(() => Value = ((SfRichTextEditor)sender).HtmlText);
Thank you for sharing the information.