diff --git a/README.md b/README.md index ee48f26..535e2a6 100644 --- a/README.md +++ b/README.md @@ -57,6 +57,7 @@ Create full C# driven hybrid-apps for iOS, Android, UWP & Desktop with Blazor! - [ITMS-90809: Deprecated API Usage - Apple will stop accepting submissions of apps that use UIWebView APIs](#itms-90809-deprecated-api-usage---apple-will-stop-accepting-submissions-of-apps-that-use-uiwebview-apis) - [Apple Rejection - Your app uses or references the following non-public APIs: LinkPresentation.framework, QuickLookThumbnailing.framework](#apple-rejection---your-app-uses-or-references-the-following-non-public-apis-linkpresentationframework-quicklookthumbnailingframework) - [Android crash at boot on API 28](#android-crash-at-boot-on-api-28) +- [Application refresh and restart after going in background](#application-refresh-and-restart-after-going-in-background) ## Updates and Migrations guides @@ -939,6 +940,16 @@ This may be related if you are building your app as an **Android App Bundles** i As stated at the top of the documentation, consider releasing your app as an **APK**. See also the [Android Build size optimization](#android-build-size-optimization) section. +### Application refresh and restart after going in background + +There is actually two cases when this behavior may happen: + +- The app has been put in background, then foreground but the HTTP port of the webserver is not available anymore for whatever reason. As it can be problematic, the app restart on a new port + +- The app started loading in the WebView, but you put the app in foreground and BlazorMobile initialization to native was not finished or Blazor WASM did not finish Blazor framework loading before getting put in background: In order to avoid inconsistent app state, the app restart. + +- Another possible issue is if you put a regular Blazor app without inheriting from **MobileApp** component, and without calling the **BlazorMobilService.Init()** code at your app start. Theses calls notify to Native that it has loaded when it's finished. If they are not present they may fallback in the second point listed here as the app believe it has not loaded properly. + ## Community - **Azure DevOps Pipeline** by [@shawndeggans](https://github.com/shawndeggans) - [Download azure-pipelines.txt]("./Community/azure-pipelines.txt") diff --git a/src/BlazorMobile.Web/Components/BlazorMobileComponent.cs b/src/BlazorMobile.Web/Components/BlazorMobileComponent.cs index 60a6e1e..1425c7d 100644 --- a/src/BlazorMobile.Web/Components/BlazorMobileComponent.cs +++ b/src/BlazorMobile.Web/Components/BlazorMobileComponent.cs @@ -119,7 +119,7 @@ protected override void BuildRenderTree(RenderTreeBuilder builder) builder.OpenElement(0, "script"); builder.AddAttribute(1, "type", "text/javascript"); - builder.AddContent(1, + builder.AddMarkupContent(1, ContextBridgeHelper.GetBlazorXamarinJavascript() + ContextBridgeHelper.GetContextBridgeJavascript().Replace("%_contextBridgeURI%", BlazorMobileService.GetContextBridgeURI())); builder.CloseElement();