jamesmontemagno / Xamarin.Plugins

Cross-platform Native API Access from Shared Code!
MIT License
1.3k stars 380 forks source link

[bug] Xam.Plugins.Vibrate - Navigation while vibrating does funny stuff #319

Closed johankson closed 8 years ago

johankson commented 8 years ago

This is a

Which plugin does this impact:

Version Number of Plugin: 2.0.0 Device Tested On: Nokia Lumia 920 Simulator Tested On: -

Expected Behavior

If the vibrate is still active at the point when one pushes a new view containing a web view with a url set the view is black. If a task.delay(slightlyLongerThanTheVibration) is added, the view loads fine.

Actual Behavior

WebView doesn't load, only a black page is displayed.

Steps to reproduce the Behavior

I can create a sample project and/or fix the bug. I just wanted to raise the issue to see if this is a known issue and if a pull request would be worth the effort to create?

Pseudo code example

The MyWebView is a view containing a single web view

<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="Views.MyWebView">
  <WebView Source="{Binding Source}"></WebView>
</ContentPage>

The ViewModel

    [ImplementPropertyChanged]
    public class MyViewModel : ViewModelBase
    {
        public void Load(string url)
        {
            Source = new UrlWebViewSource {Url = url};
        }
        public WebViewSource Source { get; set; }
    }

And the code that works and the code that doesn't

    // Doesn't work (black web view)
    CrossVibrate.Current.Vibration(200);
    var view = ServiceLocator.Current.GetInstance<MyWebView> (); 
    var vm = view.BindingContext as MyWebViewModel; 
    vm.Load (code);
    await Navigation.PushAsync (view);

    // Works fine
    CrossVibrate.Current.Vibration(200);
    await Task.Delay(210); // The difference
    var view = ServiceLocator.Current.GetInstance<MyWebView> (); 
    var vm = view.BindingContext as MyWebViewModel; 
    vm.Load (code);
    await Navigation.PushAsync (view);
jamesmontemagno commented 8 years ago

Moved to: https://github.com/jamesmontemagno/VibratePlugin/issues/1