Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Function names lost with 1.6 #159

Open
pmecho opened this issue Feb 6, 2024 · 6 comments
Open

Function names lost with 1.6 #159

pmecho opened this issue Feb 6, 2024 · 6 comments

Comments

@pmecho
Copy link

pmecho commented Feb 6, 2024

When using Compose 1.6.0, the function names are no longer available. This is reproduced in the nestedLayouts test which fails:

expected to contain:
Box:
 Box { test-tag:"root" }
 ├─Box
 ├─Column
 │ ├─Box
 │ ╰─Box
 ╰─Row
   ├─Box
   ╰─Box
but was:
:
  { test-tag:"root" }
 ├─
 ├─
 │ ├─
 │ ╰─
 ╰─
   ├─
   ╰─

at radiography.test.compose.ComposeUiTest.nestedLayouts(ComposeUiTest.kt:350)

It looks to be related to this change in Compose: https://android-review.googlesource.com/c/platform/frameworks/support/+/2741462. However, it doesn't seem as simple as calling composer.collectParameterInformation().

@pmecho
Copy link
Author

pmecho commented Feb 6, 2024

That test passes with 1.6.0-alpha05 but fails in alpha06. The alpha06 build was the first to contain that change in the description so it does seem more likely that that is the issue: https://android.googlesource.com/platform/frameworks/support/+log/9ce75ea1baa2af10dda8f787f69c40c6654bcac1..91bb8c1f81dcb031bda00fcd8e55f1e890b56f06/compose/ui

@pmecho
Copy link
Author

pmecho commented Feb 6, 2024

It looks like you can access the composer via the androidx.compose.runtime.currentComposer global val when in composition. A workaround would be to call currentComposer.collectParameterInformation() in the setContent block prior to adding any composables. I'm not quite sure what the holistic fix for this is but a few options come to mind:

  • Document that this call must be made and add it to all tests
  • Create a custom rule that calls this automatically

I wonder if this global val could also replace the reflection done in ComposeViews.tryGetLayoutInfos to get the composer. Though I'm not sure the level of refactoring that would need to be done to do that as that would require a composable scope.

@zach-klippenstein
Copy link
Collaborator

Discussed a bit offline. Radiography doesn't directly insert itself into the composition, so it's not easy to get the "current" composer in the general case. However, for this specific use case, inside a test, Radiography could probably provide a helper that would set things up correctly.

@pyricau
Copy link
Contributor

pyricau commented Feb 16, 2024

How could we make this work beyond tests? Can we grab the component from the compose view?

Also, @zach-klippenstein could this use case maybe be considered by the Compose team :) ? Is it really unreasonable to need access to an API that allows us to describe a compose hierarchy and export that somewhere?

@justin-fiedler
Copy link

justin-fiedler commented Mar 22, 2024

Hi @zach-klippenstein, thanks for this great library!

I am also running into this issue of missing names with ui-tooling:^1.6.0.

Is there any update or known workaround?

@DanGavrielov
Copy link

DanGavrielov commented Jul 15, 2024

Hi @zach-klippenstein
Was wondering if there has been any updates on this issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants