miduo/224_perf: Optimize login latency and reduce redundant I/O in so…#36
miduo/224_perf: Optimize login latency and reduce redundant I/O in so…#36Miduo666 wants to merge 6 commits intoanusii:devfrom
Conversation
|
This requires a DESCRIPTION in the PR to explain what has been done and why. Thanks. |
Hi @gjwgit , |
There was a problem hiding this comment.
Pull request overview
This PR aims to reduce login latency by avoiding repeated network work when resolving a Solid server’s OIDC issuer (and by caching the fetched WebID profile body for reuse).
Changes:
- Added an in-memory issuer-resolution cache to short-circuit repeated calls to
getIssuer. - Added an in-memory cache for fetched WebID profile document bodies plus a getter to retrieve the cached body.
- Minor doc/comment cleanup around issuer/profile helpers.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
| // Normalize the key so that trivially different representations of the same | ||
| // URL (e.g. percent-encoding variants) share a single cache entry. | ||
| final String cacheKey = Uri.parse(textUrl).toString(); | ||
|
|
There was a problem hiding this comment.
Uri.parse(textUrl) can throw a FormatException for common user-input cases (leading/trailing whitespace, embedded spaces, etc.). Because this happens before the regex fallback, it can turn previously recoverable inputs into hard failures. Consider trimming first and using Uri.tryParse(...) (or catching FormatException) and falling back to the raw/trimmed string for cacheKey when parsing fails.
There was a problem hiding this comment.
it already implemented in solidui\lib\src\widgets\solid_login.dart, line 348, final podServer = webIdController.text.trim().isNotEmpty
There was a problem hiding this comment.
Note that solid_auth may be used by another library or app other than solidpod or solidui. Therefore, it's better to ensure any leading/trailing blank-spaces in textUrl are trimmed here in solid_auth.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated 2 comments.
Comments suppressed due to low confidence (1)
lib/solid_auth_issuer.dart:134
fetchProfileDatasetsContent-Type: text/turtleon a GET request, butContent-Typedescribes the request body (which GET doesn’t have). If the intent is to request Turtle, this should be anAccept: text/turtleheader (optionally with a fallback liketext/turtle,application/n-triples;q=0.9,*/*;q=0.1) to improve compatibility with content negotiation on Solid servers.
Future<String> fetchProfileData(String profUrl) async {
final response = await http.get(
Uri.parse(profUrl),
headers: <String, String>{
'Content-Type': 'text/turtle',
},
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
lib/solid_auth_issuer.dart
Outdated
| /// Returns the profile card body that was fetched during [getIssuer], or `null` | ||
| /// if the profile has not been fetched yet (e.g. the server URL is a plain | ||
| /// issuer URI rather than a WebID URL). | ||
|
|
There was a problem hiding this comment.
The doc comment for getCachedIssuerProfileBody is split by blank (non-///) lines, so the first part becomes a dangling library doc comment and won’t be associated with the function (and may trigger dangling_library_doc_comments). Keep the comment block contiguous by using /// on blank lines or removing the blank lines between the /// lines.
| /// |
Pull Request Details
What does this PR address
This PR optimizes the OIDC issuer discovery process by eliminating redundant network requests. Previously, we fetched the WebID profile twice—once to extract the issuer URI and again during the authentication step—which added unnecessary latency. I've introduced a simple caching mechanism using two fields: _issuerCache to store the mapping between the user-input URL and the resolved issuer, and _profileBodyCache to hold the Turtle text from the initial fetch. By reusing the data we already downloaded in the first step, we cut the network overhead in half and ensure a much snappier login experience for the user.
Associated Issue
Type of Change
How Has This Been Tested?
Please describe the tests that you ran to verify your changes.
Checklist
Complete the check-list below to ensure your branch is ready for PR.
make preporflutter analyze lib)dart testoutput or screenshot included in issue #Finalising
Once PR discussion is complete and reviewers have approved: