sirhamsteralot / HaE-PBLimiter

Profiles pb's and damages them when their runtime goes over a set value
MIT License
11 stars 5 forks source link

Leaving Torch open to the PBLimiter plugin screen crashes torch #30

Closed kontu closed 6 days ago

kontu commented 4 years ago

Crash : https://pastebin.com/raw/1kBgbySB

If I go to the Plugins tab on Torch and then the HaE PBLimiter screen and then...forget to move off of it for a number of minutes (<10minutes for sure, maybe less than 5), Torch crashes everything out with the error in the above logs. I've reproduced this on 7 different Torch instances across 5 different physical boxes.

This issue existed before the recent update, I just hadn't had time to document and report it

sirhamsteralot commented 4 years ago

This is an old issue that keeps coming back and after countless attempts at fixing this i honestly dont know anymore how i would fix this. Any help would be appreciated

azazar commented 4 years ago

I'm not familiar with C# GUI libraries, but I think that it's a synchronization issue. You pass PBData.pbPair.Values to UI thread, which is a wrapper for PBData.pbPair and ValueCollection doesn't lock Dictionary object on access. That could be fixed by passing a reference to copy of that data. I'm almost sure about that.

        private void Refresh(object state)
        {
            Dispatcher.BeginInvoke(new Action(() =>
            {
                lock(PBData.pbPair)
                {
                    DataGrid1.ItemsSource = null;
                    DataGrid1.ItemsSource = PBData.pbPair.Values;
                    // ^^^^^^^^^^^^^^ I think that the problem should be on that line
                }
            }));

        }

Try replacing it with DataGrid1.ItemsSource = PBData.pbPair.Values.ToList();

sirhamsteralot commented 6 days ago

Resolved in next release, from the 2024-1 branch