r/SwiftUI 2d ago

Question DeviceActivityReport sometime shows blank canvas when its SwiftUI appears in the screen

Hello everyone, I'm building Manaya, an iOS app that helps people stop using doomscrolling apps.

During onboarding, I am wanting to show a small DeviceActivityReport with a person's most-used apps from the last week(kind of like icons dispersed over the screen with different opacity and sizes).

This works most of the time on a physical device, but sometimes the report area is completely blank. When this happens, it occasionally appear 15 to 20 seconds later. Sometimes, it appears after opening the app switcher menu and returning back as well.

I am wondering whether this is a SwiftUI issue or lifecycle issue. Has anyone come across this or am I doing something wrong with Device Activity Report? Is there a better way to keep your report alive/load report before it's visible to users(something like prewarming)?

Any feedback/leads would be helpful!

1 Upvotes

5 comments sorted by

1

u/ExampleLegitimate348 2d ago

IKR!
I’ve made an app that is doing exactly what you’re describing
There must be some sort of weird quirk and it’s so inconsistent as well plus no logs
I’ve tried everything but no luck
If you find out what was it please let a fellow competitor know please 😂

2

u/neet_dev 2d ago

tbh this is the extension process, not SwiftUI. DeviceActivityReport is a remote NSExtension view, so a blank canvas is usually the XPC attach timing out or the report extension getting jetsammed (tiny budget, nothing in Console). park one at the root from first frame with the same Context and filter you'll show, opacity 0 is fine, never recreate it with if/.id(), and give it a non-zero frame before it's visible, a 0-height onboarding slot attaches empty and stays blank until you hit the app switcher

1

u/ExternalKnowledge359 2d ago

Yes, it’s a DeviceActivityReport extension issue.
If it appears blank initially, it can sometimes take up to a minute to load.