Skip to content

Protocol activation delivered to a running Skia Android app leaves it rendering black (second MainActivity stacked) #24862

Closed

Description

@MartinZikmund

Current behavior 🐛

On Skia Android, if a custom-scheme deep link (protocol activation) is delivered to an app that is already running, the app renders a black screen from then on. Cold start renders fine.

The app is otherwise healthy: process alive, XAML tree built, activation delivered and handled, no exception logged.

Root cause: ApplicationActivity and every app head derived from it declare no LaunchMode, so Android uses the default standard mode and creates a new activity instance for every incoming intent. The deep link stacks a second MainActivity on top of the first one (adb shell dumpsys activity activities):

Hist #1: ActivityRecord{a002414}  <- new instance from the protocol intent (resumed, focused)
Hist #0: ActivityRecord{b28bdf}   <- original instance (paused)

Uno's single XAML window stays bound to the first instance, so the second instance presents nothing. Its SurfaceView never receives its relative z-order (no relativeParentId in dumpsys SurfaceFlinger --list, whereas a healthy window has relativeParentId=... z=-2).

Observed on an Android 35 (Pixel 7) emulator with the SamplesApp Android head, same build/device in all rows:

Case Screencap size Activity instances
Cold launch ~179 KB (renders) 1
Protocol intent, default flags ~15 KB (all black) 2, stacked
Protocol intent + FLAG_ACTIVITY_SINGLE_TOP (-f 0x20000000) ~179 KB (renders) 1

Expected behavior 🎯

A deep link to a running app should bring the existing window to the front and raise the protocol activation on it, without creating a second activity. ApplicationActivity.OnNewIntent already forwards the intent to NativeApplication.TryHandleIntent (its comment even mentions SingleTask), but it can only be reached if the app uses a launch mode that reuses the instance.

How to reproduce it (as minimally and precisely as possible) 🔬

  1. Create an Uno app with Skia Android (dotnet new unoapp), or use the SamplesApp Android head.
  2. Register a protocol on MainActivity exactly as in the protocol activation docs, and do not set LaunchMode:
[Activity(Exported = true, MainLauncher = true /* ... */)]
[IntentFilter(
    new[] { Android.Content.Intent.ActionView },
    Categories = new[] { Android.Content.Intent.CategoryDefault, Android.Content.Intent.CategoryBrowsable },
    DataScheme = "myscheme")]
public class MainActivity : Microsoft.UI.Xaml.ApplicationActivity
{
}
  1. Launch the app and confirm it renders:
    adb shell am start -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -n <package>/<activity>
  2. While it is running, deliver a deep link:
    adb shell am start -a android.intent.action.VIEW -d "myscheme://x"
  3. The screen is black. Check adb shell dumpsys activity activities | grep "Hist #": two MainActivity records are listed.

Workaround 🛠️

Declare a launch mode that reuses the running instance on the app's MainActivity:

[Activity(
    Exported = true,
    MainLauncher = true,
    LaunchMode = Android.Content.PM.LaunchMode.SingleTask)]

(I only verified the equivalent FLAG_ACTIVITY_SINGLE_TOP intent flag at runtime, which gives the same single-instance result. Note #18325 reports a blank UI with SingleTask when relaunching a persistently-backgrounded app, so the right default should be checked against that scenario as well.)

Renderer 🎨

Skia

Affected platforms 📱💻🖥️

Android

Uno.Sdk version (and other relevant versions) 📦

master at 47267e7 (net10.0-android, .NET SDK 10.0.400). The runtime observation above was made on master slightly earlier (f06c45a) with a control build; the code paths below were re-checked by inspection on 47267e7. I did not re-run the emulator for this report.

IDE version 🧑‍💻

N/A (command line)

Anything else we need to know? 💬

  • No app head or solution template in the repo declares a LaunchMode (SamplesApp, template), and the protocol activation doc does not mention it, so anyone following the documented Android steps hits this.
  • ApplicationActivity only has a bare [Activity(...)] without LaunchMode (source); OnNewIntent is here.
  • Separate, smaller problem on the same path: OnCreate arms the first-frame gate (L263) and ActivationPreDrawListener.OnPreDraw (source) cancels draws until _contentViewAttachedToWindow is set. That explains the missing z-order on the stacked instance, but fixing it alone does not help: the window still belongs to the other instance, so the screen stays black.
  • Suggested fix: pick a reuse launch mode and document it in the protocol activation article (and ideally set it in the templates). A fix is in progress for the first-frame gate part only.

Activity

  1. added
    kind/bug
    platform/android 🤖
    triage/untriaged
    area/skia ✏️
    project/navigation-lifecycle 🧬
    difficulty/starter 🚀
    on Oct 1, 2026
  2. added
    7.0
    on Oct 14, 2026
  3. removed
    triage/untriaged
    7.0
    on Oct 29, 2026
  4. self-assigned this
    on Nov 1, 2026
  5. added 8 commits that reference this issue on Nov 2, 2026
    d0f16ca
    cef80dc
    e7ad6fd
    f7cd365
    0484bda
    a8e8b68
    3e6c79f
    88602a0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area/skia ✏️difficulty/starter 🚀kind/bugplatform/android 🤖project/navigation-lifecycle 🧬

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions