xamarin/Xamarin.Forms

[iOS] OnResume is being called twice when the application is foregrounded

Aberta

#4.608 aberto em 2 de dez. de 2018

 (13 comentários) (0 reação) (0 responsável)C# (1.926 forks)batch import
e/5 :clock5:help wantedinactivep/iOS 🍎t/bug :bug:up-for-grabs

Métricas do repositório

Stars
 (5.644 estrelas)
Métricas de merge de PR
 (Nenhuma PRs mesclada em 30d)

Description

Steps to Reproduce

  1. Run the attached repro
  2. Background and foreground the app and observe that the counter is output to the console
  3. Background and foreground the app several times until you see OnResume fire twice in succession and the counter get updated twice

You need to fully background the app to reproduce the issue. If you simply preview the horizontal stack of running apps and bring your app back to the foreground, then the issue does not exist.

This was tested on XS / 12.1. I suspect that OnActivated is being fired twice in FormsAplicationDelegate.

Edit: I just tested iPhone 8 / 12.1, and the issue does not exist there, so this might be scoped to the new models (without the physical home button). I also noticed OnSleep seems to be firing twice as well.

Expected Behavior

OnResume should fire only once. There are some legitimate reasons for OnActivated to be called multiple times. See here, but the test code isn't doing any of those.

Also, WillEnterForeground is NOT firing sometimes when the app is foregrounded. Why?

Reproduction Link

App1.zip

References

https://bugzilla.xamarin.com/show_bug.cgi?id=59980 https://forums.xamarin.com/discussion/32272/onresume-event-fires-twice-on-android https://forums.xamarin.com/discussion/82322/onresume-is-being-called-multiple-times-when-app-is-resumed-ios

Guia do colaborador