Closed alexstyl closed 2 months ago
Can you try to rewrite this code using the anchor constraints instead of autoresize mask? It seems to me that the size could be calculated incorrectly in this code.
I tried this code and the result is the same:
let rootView = ComposeView()
.frame(maxWidth: .infinity, maxHeight: .infinity)
.background(Color.white)
let controller = UIHostingController(rootView: rootView)
self.addChild(controller)
controller.view.translatesAutoresizingMaskIntoConstraints = false
self.view.addSubview(controller.view)
controller.view.leadingAnchor.constraint(equalTo: self.view.leadingAnchor).isActive = true
controller.view.trailingAnchor.constraint(equalTo: self.view.trailingAnchor).isActive = true
controller.view.topAnchor.constraint(equalTo: self.view.topAnchor).isActive = true
controller.view.bottomAnchor.constraint(equalTo: self.view.bottomAnchor).isActive = true
controller.didMove(toParent: self)
Keep in mind that I tried the same code to render a Swift View and the contents of the Swift View were displayed correctly.
Thanks, I'll have a look
@elijah-semyonov did u have a look? could you kindly confirm that is indeed a bug in compose?
@alexstyl Yes, I reproduced it. Investigating.
UIApplication.shared
is illegal to access in App Extensions and we still wrongfully do it in order to ensure, that no drawing happens when app is in background (which it says it is, it's UB most likely anyway). Working around it will also require us to update Skia. The version we use still performs MtlIsAppInBackground
check (which does the same thing) and wrongfully exits not even trying to perform the draw logic.
This is possible to fix, but a bit later. We didn't plan supporting such a feature and didn't do any sort of investigations, so there are some implications in existing code (regarding lifecycle, etc).
Please check the following ticket on YouTrack for follow-ups to this issue. GitHub issues will be closed in the coming weeks.
Describe the bug I am trying to render Compose on a share extension. No matter what I tried, the view renders black.
Affected platforms
Versions
To Reproduce Create an iOS
Share Extension
, replace the ShareViewController with:Expected behavior The contents of the
MainViewControllerKt.ShareViewController()
to be renderedActual behavior The Compose View is rendered as a black view
Screenshots