-
-
Notifications
You must be signed in to change notification settings - Fork 254
Improve bit Boilerplate overall responsiveness in Blazor Hybrid (#11644) #11645
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
Conversation
WalkthroughTwo components are optimized for Blazor Hybrid responsiveness: SignalR connection state logic is corrected in AppClientCoordinator with proper parenthesization and Task.Run wrapping, and NoOpPrerenderStateService is refactored to add async support with conditional Task.Run execution for platform-specific optimization. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Knowledge base: Disabled due to Reviews -> Disable Knowledge Base setting
📒 Files selected for processing (2)
src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Core/Components/AppClientCoordinator.cs(1 hunks)src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Core/Services/NoOpPrerenderStateService.cs(2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (8)
- GitHub Check: build api + blazor web
- GitHub Check: build blazor hybrid (iOS-macOS)
- GitHub Check: build blazor wasm standalone
- GitHub Check: build blazor hybrid (android)
- GitHub Check: build blazor hybrid (windows)
- GitHub Check: CodeQL analysis (csharp)
- GitHub Check: Agent
- GitHub Check: build and test
🔇 Additional comments (2)
src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Core/Components/AppClientCoordinator.cs (1)
288-288: Good catch on the operator precedence bug!The parenthesization fix correctly changes the logic from
(is not Connected) or Connectingtois not (Connected or Connecting). The original code would incorrectly enter the if-block whenever the state wasConnecting, which is not the intended behavior.src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Core/Services/NoOpPrerenderStateService.cs (1)
19-25: No action required.The concern has been verified as addressed by design. The
NoOpPrerenderStateServiceis explicitly documented as a no-op implementation for non-prerendering scenarios (Blazor Hybrid), where state persistence is unnecessary. The interface contract ensures that:
- When consuming code calls
GetValuewith caller attributes (the recommended pattern), the key is derived from caller information and passed to the no-op, which safely ignores it since no persistence occurs- When real prerendering implementations (
WebClientPrerenderStateService,WebServerPrerenderStateService) are used, the key is used meaningfully for state retrieval and persistence- The empty string parameter behavior is correct: no-op implementations don't need meaningful keys because they don't persist state
The design is sound and well-documented in the interface comments.
...rplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Core/Components/AppClientCoordinator.cs
Show resolved
Hide resolved
...ate/Bit.Boilerplate/src/Client/Boilerplate.Client.Core/Services/NoOpPrerenderStateService.cs
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR aims to improve the overall responsiveness of the bit Boilerplate application in Blazor Hybrid scenarios by offloading potentially blocking operations to thread pool threads using Task.Run.
Key Changes
- Modified
NoOpPrerenderStateService.GetValueto useTask.Runfor factory execution in Blazor Hybrid scenarios - Updated SignalR connection initialization in
AppClientCoordinatorto useTask.Runfor improved responsiveness - Fixed pattern matching syntax for HubConnectionState checks (improved readability)
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
NoOpPrerenderStateService.cs |
Added conditional Task.Run execution for Blazor Hybrid to offload async factory work to thread pool; refactored method order for consistency |
AppClientCoordinator.cs |
Updated pattern matching syntax for state checks; wrapped SignalR StartAsync in Task.Run for improved responsiveness |
closes #11644
Summary by CodeRabbit
Bug Fixes
Performance