cdeutsch / JsBridge

Simpler bidirectional communication between JavaScript in a UIWebView and C# in your native app.
https://components.xamarin.com/view/jsbridge
MIT License
91 stars 22 forks source link

AddEventListener Application Crash #11

Open Onkar25 opened 5 years ago

Onkar25 commented 5 years ago

Hello Team,

I am currently using the D3 Graph in my Xamarin.iOS project. While plotting the graph on UIWebView I am adding Event Listener through AddEventListener method. But this method is calling multiple time as I visit the respective controller. So while we are switch between the controller, the application gets crash showing the below StackTrace.

StackTrace 2019-09-24 20:04:46.941 [App_Name][418:11433666] ConvertToNSExceptionAndAbort 2019-09-24 20:04:46.944 [App_Name][418:11433666] Inserted Xamarin Exception Stack Line! 2019-09-24 20:04:46.944 [App_Name][418:11433666] Name: System.InvalidOperationException 2019-09-24 20:04:46.944 [App_Name][418:11433666] Message: System.InvalidOperationException: Collection was modified; enumeration operation may not execute.Xamarin Exception Stack: at System.Collections.Generic.List1+Enumerator[T].MoveNextRare () [0x00013] in <91e0283eca55453fa9b161bf2de4edfd>:0 at System.Collections.Generic.List1+Enumerator[T].MoveNext () [0x0004a] in <91e0283eca55453fa9b161bf2de4edfd>:0 at System.Linq.Enumerable+WhereListIterator`1[TSource].MoveNext () [0x0004e] in <825255c699d046a482fee36362eb0c49>:0 at cdeutsch.JsBridge.JsEventFired (cdeutsch.FireEventData feData) [0x0005b] in <467146c6f412491191a720507ed7938e>:0 at cdeutsch.AppProtocolHandler.StartLoading () [0x00109] in <467146c6f412491191a720507ed7938e>:0

cdeutsch commented 5 years ago

Hi @Onkar25, I haven't touched this in 5 years, and don't even have the software installed to begin on it.

I can merge a PR, if you can come up with one.