question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

App Lifecycle event OnResume called more than once.

See original GitHub issue

Description

The application lifecycle event OnResume is called more than once when an application is minimised/stopped and then resumed.

image

image

Steps to Reproduce

  1. Create a new project using the “.NET MAUI App” template.
  2. Edit App.xaml.cs
  3. Add within the partial class the following:
	private int ResumeCount = 0;
  1. Add an override method for OnResume:
	protected override void OnResume()
	{
		base.OnResume();
		ResumeCount++;
		System.Diagnostics.Debug.WriteLine("{0}: Restarted {1}", DateTimeOffset.UtcNow, ResumeCount);
	}
  1. Build and launch in debug (Windows Machine):
  2. Minimise the app
  3. Restore the app
  4. In the debug output window, there will be 2 debug statements indicating: Restarted 1 Restarted 2

Version with bug

6.0 (current)

Last version that worked well

Unknown/Other

Affected platforms

Windows, I was not able test on other platforms

Affected platform versions

Android 21.0, Windows 10.0.17763.0

Did you find any workaround?

No response

Relevant log output

09/06/2022 13:29:24 +00:00: Restarted 1
09/06/2022 13:29:24 +00:00: Restarted 2

VS bug #1778056

Depends on

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:1
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
PureWeencommented, Jul 8, 2022

AFAICT this is a bug with the WinAppSdk firing the OnActivated event twice

https://github.com/microsoft/microsoft-ui-xaml/issues/7343

1reaction
GeorgeLeitheadcommented, Jun 9, 2022

I have checked the Platforms, specifically for the Windows platform, and any additional builder wire-ups, and there is nothing that I can find that the default template provides that could account for multiple invokes.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why is my onResume being called twice?
My issue with onResume being caused twice was because onPause was somehow being called after the activity was created.. something was ...
Read more >
The activity lifecycle
An Activity is an application component that provides a screen with which users can interact in order to do something, such as dial...
Read more >
App lifecycle - .NET MAUI
NET MAUI raises cross-platform lifecycle events when an app transitions between its different execution states.
Read more >
Activity Lifecycle
onResume() is called at the start of the active lifetime; more specifically, it is called at the start of the active lifetime; more...
Read more >
Jetpack Compose — Making Composable lifecycle-aware
We want to refetch our App data when the user comes from background to ... Then on OnResume lifecycle event it will call...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found