Skip to content

Commit

Permalink
Fix tracks hanging in safari and polyfill BigInt for bigwig tracks fo…
Browse files Browse the repository at this point in the history
…r safari (#3256)

* Misc

* Small refactor
  • Loading branch information
cmdcolin committed Oct 10, 2022
1 parent a0da9a6 commit 6221f6a
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 41 deletions.
12 changes: 9 additions & 3 deletions packages/core/rpc/WebWorkerRpcDriver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@ class WebWorkerHandle extends Rpc.Client {
const { statusCallback, rpcDriverClassName } = opts
const channel = `message-${shortid.generate()}`
const listener = (message: string) => {
if (statusCallback) {
statusCallback(message)
}
statusCallback?.(message)
}
this.on(channel, listener)
const result = await super.call(
Expand Down Expand Up @@ -58,6 +56,14 @@ export default class WebWorkerRpcDriver extends BaseRpcDriver {
const instance = this.makeWorkerInstance()

const worker = new WebWorkerHandle({ workers: [instance] })
const isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent)
if (isSafari) {
// eslint-disable-next-line no-console
console.log(
'console logging the webworker handle avoids the track going into an infinite loading state, this is a hacky workaround for safari',
instance,
)
}

// send the worker its boot configuration using info from the pluginManager
const p = new Promise((resolve: (w: WebWorkerHandle) => void, reject) => {
Expand Down
19 changes: 8 additions & 11 deletions plugins/alignments/src/LinearPileupDisplay/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,24 +177,22 @@ const stateModelFactory = (configSchema: LinearPileupDisplayConfigModel) =>
adapterConfig,
rendererType,
} = self
const { staticBlocks, bpPerPx } = view

if (!self.estimatedStatsReady) {
return
}
if (self.regionTooLarge) {
if (
!view.initialized ||
!self.estimatedStatsReady ||
self.regionTooLarge
) {
return
}

const { staticBlocks, bpPerPx } = view
// continually generate the vc pairing, set and rerender if any
// new values seen
if (colorBy?.tag) {
const uniqueTagSet = await getUniqueTagValues(
self,
colorBy,
staticBlocks,
self.updateColorTagMap(
await getUniqueTagValues(self, colorBy, staticBlocks),
)
self.updateColorTagMap(uniqueTagSet)
}

if (colorBy?.type === 'modifications') {
Expand All @@ -211,7 +209,6 @@ const stateModelFactory = (configSchema: LinearPileupDisplayConfigModel) =>

if (sortedBy) {
const { pos, refName, assemblyName } = sortedBy

// render just the sorted region first
await self.rendererType.renderInClient(rpcManager, {
assemblyName,
Expand Down
38 changes: 18 additions & 20 deletions plugins/alignments/src/LinearSNPCoverageDisplay/models/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,22 +160,26 @@ const stateModelFactory = (
async () => {
try {
const { colorBy } = self
const { staticBlocks } = getContainingView(self) as LGV
const view = getContainingView(self) as LGV

if (!self.estimatedStatsReady) {
return
}
if (self.regionTooLarge) {
if (
!view.initialized ||
!self.estimatedStatsReady ||
self.regionTooLarge
) {
return
}
const { staticBlocks } = view
if (colorBy?.type === 'modifications') {
const vals = await getUniqueModificationValues(
self,
getConf(self.parentTrack, 'adapter'),
colorBy,
staticBlocks,
const adapter = getConf(self.parentTrack, 'adapter')
self.updateModificationColorMap(
await getUniqueModificationValues(
self,
adapter,
colorBy,
staticBlocks,
),
)
self.updateModificationColorMap(vals)
}
} catch (error) {
console.error(error)
Expand Down Expand Up @@ -222,25 +226,19 @@ const stateModelFactory = (
label: 'Draw insertion/clipping indicators',
type: 'checkbox',
checked: self.drawIndicatorsSetting,
onClick: () => {
self.toggleDrawIndicators()
},
onClick: () => self.toggleDrawIndicators(),
},
{
label: 'Draw insertion/clipping counts',
type: 'checkbox',
checked: self.drawInterbaseCountsSetting,
onClick: () => {
self.toggleDrawInterbaseCounts()
},
onClick: () => self.toggleDrawInterbaseCounts(),
},
{
label: 'Draw arcs',
type: 'checkbox',
checked: self.drawArcsSetting,
onClick: () => {
self.toggleDrawArcs()
},
onClick: () => self.toggleDrawArcs(),
},
]
},
Expand Down
2 changes: 1 addition & 1 deletion plugins/bed/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
},
"dependencies": {
"@flatten-js/interval-tree": "^1.0.15",
"@gmod/bbi": "^2.0.2",
"@gmod/bbi": "^2.0.3",
"@gmod/bed": "^2.1.2",
"@gmod/bgzf-filehandle": "^1.4.3",
"@gmod/tabix": "^1.5.2"
Expand Down
2 changes: 1 addition & 1 deletion plugins/variants/src/VcfTabixAdapter/VcfTabixAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export default class extends BaseFeatureDataAdapter {
const { refName, start, end } = query
const { vcf, parser } = await this.configure()
await vcf.getLines(refName, start, end, {
lineCallback: (line: string, fileOffset: number) => {
lineCallback: (line, fileOffset) => {
observer.next(
new VcfFeature({
variant: parser.parseLine(line),
Expand Down
2 changes: 1 addition & 1 deletion plugins/wiggle/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"clean": "rimraf dist esm *.tsbuildinfo"
},
"dependencies": {
"@gmod/bbi": "^2.0.2",
"@gmod/bbi": "^2.0.3",
"@mui/icons-material": "^5.0.2",
"@popperjs/core": "^2.11.0",
"clone": "^2.1.2",
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1537,10 +1537,10 @@
object.entries-ponyfill "^1.0.1"
quick-lru "^2.0.0"

"@gmod/bbi@^2.0.2":
version "2.0.2"
resolved "https://registry.yarnpkg.com/@gmod/bbi/-/bbi-2.0.2.tgz#33f343ad46cce789d3e8e1de348bf1a69d19f538"
integrity sha512-6sReScRL9it2jCjMFRjLOFiU4+gS8Uzx2d7rBcnb1izktAxMFvR1TPXtzP4MPvYYSiv1W/rxtOOz2iItKDkq/A==
"@gmod/bbi@^2.0.3":
version "2.0.3"
resolved "https://registry.yarnpkg.com/@gmod/bbi/-/bbi-2.0.3.tgz#961a0beb0b7406289d6c4ba4977939610668a09c"
integrity sha512-dFZi1SHBLhVPhsaGXE9yP5gRGQyoBp6u3TthkoYYLee5p7RJI0imzlVrF1/tYSAV484Rd985s04gwjBjbWVfzA==
dependencies:
abortable-promise-cache "^1.4.1"
binary-parser "^2.1.0"
Expand Down

0 comments on commit 6221f6a

Please sign in to comment.