xamarin/Xamarin.Forms

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

开放

#4,608 创建于 2018年12月2日

 (13 条评论) (0 个反应) (0 位负责人)C# (1,926 个派生)batch import
e/5 :clock5:help wantedinactivep/iOS 🍎t/bug :bug:up-for-grabs

仓库指标

星标
 (5,644 个星标)
PR 合并指标
 (30 天内没有已合并 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

贡献者指南