LearnNewsExamplesServices
Frontmatter
id6043
titleAppworker based Delta Updates
stateClosed
labels
enhancementepicdeveloper-experience
assigneestobiu
createdAtOct 27, 2024, 11:18 PM
updatedAtNov 11, 2024, 9:59 AM
githubUrlhttps://github.com/neomjs/neo/issues/6043
authortobiu
commentsCount1
parentIssuenull
subIssues[]
subIssuesCompleted0
subIssuesTotal0
blockedBy[]
blocking[]
closedAtNov 11, 2024, 9:59 AM

Appworker based Delta Updates

Closed v8.1.0 enhancementepicdeveloper-experience
tobiu
tobiu commented on Oct 27, 2024, 11:18 PM

This one is a huge epic.

I will work on it inside a separate feature branch, until it gets stable. Draft PR to track the progress: https://github.com/neomjs/neo/pull/6042

The goal is to keep the rendering logic inside the vdom worker, but move the delta updates logic inside the app worker.

In depth: When updates happen within the vdom worker, we send the vdom & vnode trees over. before we are getting the new vnode back, no updates must happen, since this corrupts the state (wrong deltas). While it is manageable for components itself, it becomes extremely complex since no updates can happen, in case any parent is already updating.

Since we want sub-component updates soon, updates can also not happen, in case any child vdom tree is updating. The bookkeeping logic would get as expensive as the parsing for updates itself.

So, the goal is to change the operation to generate the new vnode into a sync OP, in which case we no longer need the bookkeeping at all. Applying the deltas within the main thread (browser window) will of course still be async.

tobiu added the developer-experience label on Oct 27, 2024, 11:18 PM
tobiu added the enhancement label on Oct 27, 2024, 11:18 PM
tobiu added the epic label on Oct 27, 2024, 11:18 PM
tobiu assigned to @tobiu on Oct 27, 2024, 11:18 PM
tobiu referenced in commit cae4ccc - "#6043 removing the old vdom.Helper, importing the new singletons into the app & vdom worker, component.Base: using the new rendering remote method" on Oct 27, 2024, 11:20 PM
tobiu referenced in commit f22ed99 - "#6043 component.Base: executeVdomUpdate() => using the new UpdateHelper & simplifying the logic" on Oct 27, 2024, 11:32 PM
tobiu referenced in commit 448b82b - "#6043 removed the useVdomWorker framework config" on Oct 27, 2024, 11:39 PM
tobiu referenced in commit c16e418 - "#6043 component.Base: removed the isVdomUpdating config" on Oct 27, 2024, 11:53 PM
tobiu referenced in commit dddd2b7 - "#6043 component.Base: removed isParentVdomUpdating()" on Oct 27, 2024, 11:55 PM
tobiu referenced in commit 24ba7c9 - "#6043 component.Base: removed needsParentUpdate()" on Oct 28, 2024, 12:03 AM
tobiu referenced in commit db3e191 - "#6043 component.Base: removed childUpdateCache" on Oct 28, 2024, 12:27 AM
tobiu
tobiu Nov 11, 2024, 9:59 AM

While this happens very rarely, I am going to hold off on this one. @rwaters

I missed the point, that in case we are running vdom OPs inside the app & vdom worker, vnode ids will no longer be unique (due to 2 separate id generators).

My first thought that this could be easily resolved with using a SAB: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer

=> Storing the dynamic vnode id counter inside of it so that both workers have direct access to the shared counter for creating ids.

However, SABs are now strictly limited to cross origin isolation: https://web.dev/articles/cross-origin-isolation-guide

In case it is not enabled (e.g. inside the webpack dev server or the Webstorm dev server), the SAB ctor is simply undefined.

I do get the point, that worker files (scripts) need to share the same origin, but enforcing entire apps to do it goes too far.

While it often is a good thing to go for COI, enforcing it for all future neo apps goes is not reasonable.

With the v8 release, we will get scoped vdom updates which can drastically reduce the footprints of search trees and worker messages. While we could move the entire vdom engine into the app worker, having the buffering to get less tree parsing is also something we do not want to lose.

tobiu closed this issue on Nov 11, 2024, 9:59 AM
tobiu cross-referenced by PR #6042 on Nov 11, 2024, 10:00 AM