Skip to content
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

Allow using web worker RPC on embedded LGV #3276

Merged
merged 4 commits into from
Oct 18, 2022
Merged

Allow using web worker RPC on embedded LGV #3276

merged 4 commits into from
Oct 18, 2022

Conversation

cmdcolin
Copy link
Collaborator

@cmdcolin cmdcolin commented Oct 17, 2022

This allows the user to manually configure web worker RPC for the embedded LGV. I sort of rushed as i ususally do to get this kind of wired up, but it seems to work. Can try the "deep_sequencing" track to see the difference in the storybook between the instance with webworker and without, the scroll jank much less affected on the webworker version

The web worker is not enabled by default, and is instead a manual process that the developer follows, because I do not want to make too many presumptions about the users bundler, and by making it a function (makeWorkerInstance) that they manually have to pull in to use, it would get easily tree-shaken and ignored and not cause build errors if they do not use the makeWorkerInstance function

a demo of this in the storybook actually appears to work as they use webpack 5, and looks like the below

import { createViewState, makeWorkerInstance, ... } from '@jbrowse/react-linear-genome-view'

export const WithWebWorker = () => {
  const state = createViewState({
    assembly,
    tracks,
    configuration: {
      rpc: {
        defaultDriver: 'WebWorkerRpcDriver',
      },
    },
    makeWorkerInstance,
  })
  return <JBrowseLinearGenomeView viewState={state} />
}

fixes #2942

@github-actions github-actions bot added the needs label triage Needs a label to show in changelog (breaking, enhancement, bug, documentation, or internal) label Oct 17, 2022
@cmdcolin cmdcolin added enhancement New feature or request and removed needs label triage Needs a label to show in changelog (breaking, enhancement, bug, documentation, or internal) labels Oct 17, 2022
@cmdcolin cmdcolin changed the title Allow using web worker RPC on embedded Allow using web worker RPC on embedded LGV Oct 17, 2022
@cmdcolin cmdcolin force-pushed the rpc_embedded branch 2 times, most recently from e9f81d2 to 30ad46f Compare October 17, 2022 20:13
@cmdcolin
Copy link
Collaborator Author

one way to isolate makeWorkerInstance even more would be to make it part of a separate package the user has to download to use. it is sort of convenient as is though, and also can be seen in the storybook which is kinda nice.

we could try a release with just this PR's approach, and if it causes problems, could consider externalizing into another package

@cmdcolin
Copy link
Collaborator Author

{ MainThreadRpcDriver: { type: 'MainThreadRpcDriver' } },
{
MainThreadRpcDriver: { type: 'MainThreadRpcDriver' },
WebWorkerRpcDriver: { type: 'WebWorkerRpcDriver' },
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure if there is any reason to avoid just making the webworkerrpc config available, reduces the boilerplate in apps that want to use webworker rpc hence this diff

@@ -88,7 +88,6 @@ export default function RootModel(
),
savedSessionsVolatile: observable.map({}),
textSearchManager: new TextSearchManager(pluginManager),
pluginManager,
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rider change, but this looked unused, and probably better to not have it unnecessarily. pluginmanager can/should be obtained from getEnv

@codecov
Copy link

codecov bot commented Oct 17, 2022

Codecov Report

Merging #3276 (231e520) into main (c234d2e) will decrease coverage by 0.13%.
The diff coverage is 11.11%.

@@            Coverage Diff             @@
##             main    #3276      +/-   ##
==========================================
- Coverage   59.52%   59.39%   -0.14%     
==========================================
  Files         676      678       +2     
  Lines       28807    28859      +52     
  Branches     7041     7041              
==========================================
- Hits        17148    17141       -7     
- Misses      11385    11444      +59     
  Partials      274      274              
Impacted Files Coverage Δ
packages/core/rpc/configSchema.ts 66.66% <ø> (-33.34%) ⬇️
products/jbrowse-desktop/src/StartScreen/util.tsx 0.00% <ø> (ø)
.../jbrowse-react-linear-genome-view/src/rpcWorker.ts 0.00% <0.00%> (ø)
...wse-react-linear-genome-view/src/workerPolyfill.js 0.00% <0.00%> (ø)
products/jbrowse-web/src/rootModel.ts 54.73% <ø> (ø)
products/jbrowse-web/src/Loader.tsx 61.90% <50.00%> (-1.38%) ⬇️
...-linear-genome-view/src/createModel/createModel.ts 60.00% <75.00%> (-2.50%) ⬇️
...se-react-linear-genome-view/src/createViewState.ts 51.85% <100.00%> (+1.85%) ⬆️
...rative-view/src/ServerSideRenderedBlockContent.tsx 64.00% <0.00%> (-4.00%) ⬇️
... and 3 more

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@cmdcolin
Copy link
Collaborator Author

modified now so that the "ES5" build (used in nodejs and bundlers that don't use the "module" field of package.json) don't have the makeWorkerInstance and the "ESM" (most bundlers) can use makeWorkerInstance

@cmdcolin
Copy link
Collaborator Author

maybe can merge and see how it goes :)

@cmdcolin cmdcolin merged commit 8885519 into main Oct 18, 2022
@cmdcolin cmdcolin deleted the rpc_embedded branch October 18, 2022 21:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow embedded components to use webworker
1 participant