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

Brings ViewStarter to the UI update. #620

Merged
merged 21 commits into from
Jan 7, 2022

Conversation

rjrjr
Copy link
Contributor

@rjrjr rjrjr commented Jan 5, 2022

This is entirely a merge PR, except for the last commit. That one replicates the work from #602 , and should be reviewed please.

rjrjr and others added 20 commits December 9, 2021 12:35
Fixes a problem where `launchWhenAttached` would crash if it failed to fetch a
resource name when trying to make a cute scope name. I happen to know of some
view systems that break our assumption that every id is named.
View.launchWhenAttached tolerates strange ids
…moving the cursor to the ends of the string being edited.
Fixes index out of bounds crash in hello-todo-terminal sample
Fixes #597.

It used to be the case that every `DecorativeViewFactory` called
`showRendering()` twice (#397). We fixed that (we thought) by introducing the
`initializeView` lambda to `ViewRegistry.buildView` and
`DecorativeViewFactory` (#408).

Unfortunately, that fix botched recursion. Individual `DecorativeViewFactory`
instances work fine, but if you wrap them you still get one `showRendering`
call from each. Worse, upstream `initializeView` lambdas are clobbered by
immediately downstream ones. e.g., when a `WorkflowViewStub` shows a
`DecorativeViewFactory`, the `WorkflowLifecycleRunner.installOn` call in the
former is clobbered.

The fix is to completely decouple building a view from from this kind of
initialization. `ViewRegistry.buildView` and its wrappers no longer try to
call `showRendering` at all.

Instead the caller of `buildView` (mostly `WorkflowViewStub`) is reponsible
for immediately calling `View.start` on the new `View`. `View.start` makes
the initial `showRendering` call that formerly was the job of
`ViewFactory.buildView` -- the factory builds the view, and the container
turns the key. Since `View.start` is called only after all wrapped
`ViewFactory.buildView` functions have executed, we're certain it will only
happen once.

Of course we still need the ability to customize view initialization via
wrapping, especially to invoke `WorkflowLifecycleOwner.installOn`. To
accomodate that, the function that `View.start` executes can be wrapped via
the new `viewStarter` argument to `ViewRegistry.buildView` and
`DecorativeViewFactory`, which replaces `initializeView`.

This required a pretty thorough overhaul of `ViewShowRendering.kt`
The `ViewShowRenderingTag` that it hangs off of a view tag is renamed
`WorkflowViewState`, and extracted to a separate file.

`WorkflowViewState` is a sealed class with two implementations (`New` and
`Started`) to help us enforce the order of the `ViewRegistry.buildView`,
`View.bindShowRendering`, `View.start` and `View.showRendering` calls.
Replaces *.initializeView with *.viewStarter
Because the [releases page](https://github.com/square/workflow-kotlin/releases) is so much nicer.
When moving Workers to being wrapped by WorkerWorkflow we did not need to compare
types included in the KType signature but that was not clear from the kdoc. Update
that to make it clear.
Gradle 7.3.2 adds dependency constraints to the _build_ classpath to reject known-bad versions of log4j.

See also https://blog.gradle.org/log4j-vulnerability.
Use Gradle 7.3.2. Log4shell mitigation.
Upgrade the compile SDK to 31.
Moves us to s01.oss.sonatype.org
* origin/main:
  Upgrade the compile SDK to 31.
  Moves us to s01.oss.sonatype.org
  Fixes version name after 1.3.0 release, forgot to bump it.
  Use Gradle 7.3.2. Log4shell mitigation.
  608: Update TypedWorker kdoc
  Releasing v1.3.0
  End CHANGELOG.md
  Replaces *.initializeView with *.viewStarter
  Adds (failing) DecorativeViewFactory double update test
  Fixes index out of bounds crash when attempting to add characters or moving the cursor to the ends of the string being edited.
  View.launchWhenAttached tolerates strange ids
@rjrjr rjrjr force-pushed the ray/viewstarter-to-ui-update branch 2 times, most recently from 847de16 to 8c31040 Compare January 5, 2022 23:34
Propagates changes from #602 -- replace `initializeView`
with `viewStarter` to fix #597.
@rjrjr rjrjr force-pushed the ray/viewstarter-to-ui-update branch from 8c31040 to f0dce22 Compare January 6, 2022 00:39
@rjrjr
Copy link
Contributor Author

rjrjr commented Jan 6, 2022

Having trouble seeing why the espresso tests are timing out. Not consistently happening at the same point, and they pass locally in a reasonable amount of time. Maybe infra? Rolling the dice again this morning.

@steve-the-edwards
Copy link
Contributor

Having trouble seeing why the espresso tests are timing out. Not consistently happening at the same point, and they pass locally in a reasonable amount of time. Maybe infra? Rolling the dice again this morning.

Reviewed last commit and looks good. Are you still waiting for green before taking this out of draft?

@rjrjr
Copy link
Contributor Author

rjrjr commented Jan 6, 2022

Having trouble seeing why the espresso tests are timing out. Not consistently happening at the same point, and they pass locally in a reasonable amount of time. Maybe infra? Rolling the dice again this morning.

Reviewed last commit and looks good. Are you still waiting for green before taking this out of draft?

Yes. Seems a lot more likely that I've broken something than that CI is actually being bad.

@rjrjr rjrjr marked this pull request as ready for review January 7, 2022 19:14
@rjrjr rjrjr requested review from zach-klippenstein and a team as code owners January 7, 2022 19:14
@rjrjr rjrjr requested a review from a team as a code owner January 7, 2022 19:14
@rjrjr
Copy link
Contributor Author

rjrjr commented Jan 7, 2022

Cool cool cool, turned on debugging and now it's green.

Copy link
Contributor

@steve-the-edwards steve-the-edwards left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@rjrjr rjrjr merged commit 6099c59 into ray/ui-update Jan 7, 2022
@rjrjr rjrjr deleted the ray/viewstarter-to-ui-update branch January 7, 2022 19:17
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

Successfully merging this pull request may close these issues.

None yet

5 participants