Skip to content

Stackflow transition breaks when activity suspends longer than transitionDuration #472

@XiNiHa

Description

@XiNiHa

Currently, Stackflow activities' enter transition is only expressed with enter-active and enter-done. However, this doesn't work well with frameworks that do concurrent rendering because the core state update happens regardless of whether activities render synchronously or suspend during render. This results in something like this:

sequenceDiagram
    participant Core as @stackflow/core
    participant Integration as Integration (@stackflow/react)
    participant View
    View->>Core: push()
    activate Core
    note left of Core: Transition
    Core->>Integration: notify on subscribe() listener
    Integration->>Core: getStack()
    Core->>Integration: State with `enter-active`
    Integration->>View: Render new activity with `enter-active`
    activate View
    note right of View: Suspend
    Core->>Integration: notify on subscribe() listener
    deactivate Core
    Integration->>Core: getStack()
    Core->>Integration: State with `enter-done`
    Integration->>View: Rerender with `enter-done`
    deactivate View
    note right of View: Initial render with `enter-done`
Loading

As described above, if the view suspends longer than the core transition, the initial render of the view is done with enter-done state, resulting in broken CSS transitions.

To mitigate this, the core transition should be started after confirming that the initial view was rendered. These are the required parts to implement the feature:

  • Add a new transition state to express activities that didn't complete the initial render. (enter-pending?)
  • Add a new action that notifies the core after completing the initial render. (no idea about naming 🥲)

I'm willing to implement the feature after the direction is fixed.

Related: #434

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions