xamarin/Xamarin.Forms

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

オープン

#4,608 opened on 2018/12/02

 (13 件のコメント) (0 件のリアクション) (0 人の担当者)C# (1,926 件のフォーク)batch import
e/5 :clock5:help wantedinactivep/iOS 🍎t/bug :bug:up-for-grabs

Repository metrics

Stars
 (5,644 個のスター)
PR merge metrics
 (30d に merged PR はありません)

説明

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

コントリビューターガイド