Baseflow / Baseflow/XF-Material-Library
Quick tapping crashes MaterialSnackbar
- Dominant language
- C#
- Stars
- 633
- Forks
- 150
- PR merge metrics
- No merged PRs in 30d
Description
## 🐛 Bug Report
If the UI thread is busy, or a weak device is used, then it becomes possible to call ActionButton.Command multiple times with quick clicks, as a result, after the second pressing InputTaskCompletionSource?.SetResult throws an exception
Is there any reason not to use TrySetResult ?
```
internal MaterialSnackbar(string message, string actionButtonText, int msDuration = DurationLong, MaterialSnackbarConfiguration configuration = null)
{
...
var primaryActionCommand = new Command(async () =>
{
_primaryActionRunning = true;
await DismissAsync();
InputTaskCompletionSource?.TrySetResult(true);
}, () => !_primaryActionRunning);
...
}
```
#### Stack trace ####
```
XF.Material.Forms.UI.Dialogs.MaterialSnackbar.<.ctor>b__6_0 () [0x0007a] in <3cfa98f1ecd344d8b7c2286276967650>:0;XF.Material.Forms.UI.Dialogs.MaterialSnackbar
TaskCompletionSource`1[TResult].SetResult (TResult result)
<.ctor>b__6_0 ()
AsyncMethodBuilderCore+<>c.b__7_0 (System.Object state)
SyncContext+<>c__DisplayClass2_0.b__0 ()
Thread+RunnableImplementor.Run ()
IRunnableInvoker.n_Run (System.IntPtr jnienv, System.IntPtr native__this)
```
#### Reason ####
System.InvalidOperationException: System.InvalidOperationException
### Expected behavior
The app should not crash
### Reproduction steps
### Configuration
**Version:** 1.x
**Platform:**
- [ ] :iphone: iOS
- [x] :robot: Android
- [ ] :checkered_flag: WPF
- [ ] :earth_americas: UWP
- [ ] :apple: MacOS
- [ ] :tv: tvOS
- [ ] :monkey: Xamarin.Forms
Contributor guide
Assessment
This issue has not been assessed yet.