Improve design to limit rendering latency for records with many properties #374
No reviewers
Labels
No labels
bug
config
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
orinoco/shacl-vue!374
Loading…
Reference in a new issue
No description provided.
Delete branch "many-parts"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
The problem this new approach aims to solve is the bad UX of waiting several
(tens of) seconds for a record with thousands of related nodes to render. It
came to light when rendering a file with thousands of parts. This is likely a
minor representation of the issue, which will worsen with larger records.
The new approach aims to do defer the maximum amount of processing until the
latest possible timepoint. Previous work in
3501e82380already paved the wayfor solving the current record rendering challenge. That commit introduced the
new record handling approach, a.k.a. maintaining a global list of items that is
incrementally updated when new nodes are added to or updated in the graph. This
global list of items also contains information about related nodes, preflabels,
and displayLabels. So it already calculated and contains information required
by the current record viewer, which currently ignored that and just recalculated
everything itself.
The new approach firstly involves minimal processing upfront when a record is
first fetched form the backend. It only indexes related nodes (not recursively)
but now in the structure expected by the NodeShapeViewer, i.e. divided into
termType triples. The minimally processed item that is now part of the global
list of items (recordItemsAll) is accessed in the NodeShapeViewer when it first
mounts. The NodeShapeViewer then takes an on-demand approach to processing
related nodes (i.e. its properties). For each property, on first mount it will
process up to the 'stepsize'-configured amount of values (e.g. 5) in order to
fetch nodes related to that property value and to calculate the display label
of that property value. Furthermore the same on-demand processing happens only
when the user hits the + button which changes the index-shown value of the
MoreOrLessRecordsViewer for that particular property. This replaces the previous
approach of the NodeShapeViewer where it calculated everything from scratch at
component mounting time using the quad prop.
Newly introduced functionality in the NodeShapeViewer includes:
processing for all properties and values that will be rendered by default (i.e.
they are fewer than the default displayed step size, e.g. 5. This minimal processing
is handled by updateNamedNodeProperty() and updateBlankNodeProperty())
on-demand. Updating involves sometimes fetching related nodes and subsequently
determining label details from related nodes. The point is to have readily available
display label and preflabel information for rendering.
in the global list of items to finish processing (after a triggered fetch) so that
the NodeShapeViewer functionality can be sure that the item contains label details
that are necessary for further processing.
item in recordItemsAll into a local reactive object, and does the rest of the processing
for updating on that object. In contrast, after a record is edited and saved, the
updateItem function builds up the item from scratch directly from the graph (using new
useRecords utilities, specifically constructItem), i.e. it doesn't copy the state from
recordItemsAll. This was necessary because the edited changes did not want to render as
expected after a record save, if the normal updateItem was run. This issue caused much
frustration and lots of wasted time trying to debug. The end-result, which now does what
is expected, is therefore not in the current state by perfect design, but by necessity
and as a solution to the to-me inexplicable Vue reactivity problem.
ordered alphanumerically; this means that the rendered index of a value might change
if the user hits the + or - buttons to show more or fewer values of a property. This
was done as a second-prize, to still allow sorting while not being able to sort all
values since all values' display labels might not have been generated yet due to the
new on-demand approach.
Another note on the waitForRecordProcessing() function and its use. When the
NodeShapeViewer uses fetchFromService to fetch a record, the expected outcome is that
the record is fetched and processed by useRecords' updateRecordItem function, and then
it ends up in recordItemsAll. It could be the case that the fetched record was already
in recordItemsAll prior to the fetch (in which case the fetch is skipped), or that the
record could not be fetched at all (perhaps it doesn't exist in the backend, perhaps
there was an http error). So the result from fetchFromService is first tested:
results?.status?.includes('success') || results?.status?.includes('skipped')
and only if this condition is met can we be certain that the record exists in recordItemsAll
and only then can waitForRecordProcessing be called without fear of a timeout error.
To support this process, the useData composable needed to be updated to:
(TODO: fetchedRequests seemed to suffer from a race condition and could not
persistently and correctly pick up whether a record already existsed or was fetched
or not)
'get-record' endpoint which is the one used in the NodeShapeViewer when a related
record is fetched.
To support all of the above, the useRecords composable was updated to do the minimal upfront
processing and also to set a status flag when it has finished processing a new or
updated item. It also underwent a bit of refactoring to make the code more understandable
and allow the constructItem to be used in the composable as well as to be exported for
use by the NodeShapeViewer.
Lastly, to reduce onMount processing for the NodeShapeViewer even more, the backlink viewer
functionality was disabled, by commenting out the associated lines of code. It will
be brought back in a future commit, but via a user-clickable interface, i.e. it will
not be displayed upfront by default.
8c689ce7a9tocc08f69a55