Repository navigation
Feat/UI locking - #26804
Open
OriginalFelix wants to merge 10 commits into
Open
Feat/UI locking#26804OriginalFelix wants to merge 10 commits into
OriginalFelix wants to merge 10 commits into
Conversation
Moves the UI bookkeeping out of VaadinSession into a new SessionUIService owned by VaadinService. It holds a ConcurrentHashMap<VaadinSession, CopyOnWriteArrayList<UI>>, so UIs can be enumerated lock-free. VaadinSession keeps its public API and delegates to the service. - Session destroy removes the session entry to avoid leaks. - Serialization keeps the Map<Integer, UI> stream format; UIs are held locally after deserialization and moved to the service in refreshTransients. - Falls back to a session local store when the service provides none (e.g. mocked services). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TKXmkBLF5XfNVJ3CFAYj7v
With the uiLocking init parameter, updating a UI locks only that UI, so UIs of one session (browser tabs) are updated in parallel. - UIDL, heartbeat and push messages lock the UI, not the session. - UI.access() uses a queue per UI, pushed when the UI lock is released. - Session state (attributes, registries, ids) is thread-safe and accessible while holding a UI lock. - Lock order: a UI lock holder may wait for the session lock; a session lock holder never waits for a UI lock (tryLock or UI.access()). - Spring and CDI session scopes lock the session for shared bookkeeping. Disabled by default; session locking is unchanged.
# Conflicts: # flow-server/src/main/java/com/vaadin/flow/server/SynchronizedRequestHandler.java # flow-server/src/main/java/com/vaadin/flow/server/VaadinService.java # flow-server/src/main/java/com/vaadin/flow/server/communication/PushHandler.java # flow-server/src/main/java/com/vaadin/flow/server/communication/StreamReceiverHandler.java # flow-server/src/main/java/com/vaadin/flow/server/communication/StreamRequestHandler.java # flow-server/src/test/java/com/vaadin/flow/server/VaadinServiceTest.java
Make SessionUIService serializable, as required for all Flow classes, and read the session state with the lock held in the session destroy test.
Contributor
|
Thanks a lot for working on this! We went through the PR in detail against the design discussed in #24187. Below is a summary of what we found, followed by a proposal for how to get this in. What the PR gets right
Problems
Proposed way forwardBecause the change touches the core threading model, we'd like to land it in smaller, reviewable steps rather than as one PR. We've split #24187 into sub-issues (linked from the issue):
Much of the code in this PR can be reused in those steps. Steps 1–2 are safe refactors that can merge quickly and make step 3, the actual concurrency change, much smaller to review. |
This was referenced Dec 1, 2026
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR adds UI-Locking behind a Feature-Flag. Reason is that always taking the Lock even when a Component is Updated blocks every UI from Working so Updates can be slow when there are many of them.
This PR separates UI Relevant Updates from Session-Updates and adds a new Lock. (Only if the Feature-Flag is enabled)
Fixes #24187
This PR adds UI-Locking behind a Feature-Flag. Old behavior remains untouched without the flag.
Checklist
Additional for
Featuretype of change