Quantcast
Channel: Active questions tagged blazor - Stack Overflow
Viewing all articles
Browse latest Browse all 4839

Android MAUI WebView in Background Stops Processing after 5 Minutes

$
0
0

I'm developing an Android app using MAUI-hybrid with a Blazor-WebView. The app receives packets from a smart pen via Bluetooth and draws strokes on a canvas using the perfect-freehand library.

Problem:When the app is sent to the background (either by switching to another app or turning off the screen), it continues to process incoming packets and draw strokes for about 5 minutes. After that, while the MAUI layer still receives the packets, they are not being processed by the Blazor-WebView.

Observed Behavior:For the first 5 minutes in the background, everything works fine - strokes are drawn and stored in the DB.After 5 minutes, the await js.InvokeVoidAsync("onDeviceNotification", id, val, mac); call seems to hang.When the app is brought back to the foreground, all the queued packets are processed sequentially and correctly.

What I've Tried:

  1. Implemented a ForegroundService to keep the app running in the background.
  2. Used PowerManager.WakeLock to prevent the CPU from sleeping.
  3. Added WebView settings to allow background JavaScript execution:
if (Build.VERSION.SdkInt >= BuildVersionCodes.P){    e.WebView.SetRendererPriorityPolicy(RendererPriority.Important, false);}

Question:How can I keep the WebView (Blazor) active and processing JavaScript calls continuously while the app is in the background on Android, even after 5 minutes? Given that this issue doesn't occur on iOS, are there specific Android optimizations or settings I'm missing?Any insights or suggestions on how to maintain WebView activity in the background for extended periods on Android, possibly mimicking the behavior we see on iOS, would be greatly appreciated.

Additional Information:Target Android version: 33MAUI version: 7


Viewing all articles
Browse latest Browse all 4839

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>