xamarin/Xamarin.Forms

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

Aperta

#4608 aperta il 2 dic 2018

 (13 commenti) (0 reazioni) (0 assegnatari)C# (1926 fork)batch import
e/5 :clock5:help wantedinactivep/iOS 🍎t/bug :bug:up-for-grabs

Metriche repository

Star
 (5644 stelle)
Metriche merge PR
 (Nessuna PR mergiata in 30 g)

Descrizione

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

Guida contributor