Frontmatter
| id | 6043 |
| title | Appworker based Delta Updates |
| state | Closed |
| labels | enhancementepicdeveloper-experience |
| assignees | tobiu |
| createdAt | Oct 27, 2024, 11:18 PM |
| updatedAt | Nov 11, 2024, 9:59 AM |
| githubUrl | https://github.com/neomjs/neo/issues/6043 |
| author | tobiu |
| commentsCount | 1 |
| parentIssue | null |
| subIssues | [] |
| subIssuesCompleted | 0 |
| subIssuesTotal | 0 |
| blockedBy | [] |
| blocking | [] |
| closedAt | Nov 11, 2024, 9:59 AM |
Appworker based Delta Updates

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.
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&vnodetrees 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
syncOP, in which case we no longer need the bookkeeping at all. Applying the deltas within the main thread (browser window) will of course still beasync.