fix ui: fix chrome crash code11
This commit is contained in:
parent
49e35cb329
commit
04240ce9b3
4 changed files with 35 additions and 12 deletions
|
|
@ -274,9 +274,9 @@ export default class MessageManager {
|
||||||
|
|
||||||
public changeTab(tabId: string) {
|
public changeTab(tabId: string) {
|
||||||
this.activeTab = tabId;
|
this.activeTab = tabId;
|
||||||
this.state.update({ currentTab: tabId });
|
|
||||||
this.tabs[tabId].clean();
|
this.tabs[tabId].clean();
|
||||||
this.tabs[tabId].move(this.state.get().time);
|
this.tabs[tabId].move(this.state.get().time);
|
||||||
|
this.state.update({ currentTab: tabId });
|
||||||
}
|
}
|
||||||
|
|
||||||
public updateChangeEvents() {
|
public updateChangeEvents() {
|
||||||
|
|
|
||||||
|
|
@ -342,7 +342,6 @@ export default class TabSessionManager {
|
||||||
|
|
||||||
Object.assign(stateToUpdate, this.lists.moveGetState(t));
|
Object.assign(stateToUpdate, this.lists.moveGetState(t));
|
||||||
Object.keys(stateToUpdate).length > 0 && this.updateLocalState(stateToUpdate);
|
Object.keys(stateToUpdate).length > 0 && this.updateLocalState(stateToUpdate);
|
||||||
|
|
||||||
/* Sequence of the managers is important here */
|
/* Sequence of the managers is important here */
|
||||||
// Preparing the size of "screen"
|
// Preparing the size of "screen"
|
||||||
const lastResize = this.resizeManager.moveGetLast(t, index);
|
const lastResize = this.resizeManager.moveGetLast(t, index);
|
||||||
|
|
|
||||||
|
|
@ -422,11 +422,10 @@ export default class DOMManager extends ListWalker<Message> {
|
||||||
*/
|
*/
|
||||||
async moveReady(t: number): Promise<void> {
|
async moveReady(t: number): Promise<void> {
|
||||||
this.moveApply(t, this.applyMessage)
|
this.moveApply(t, this.applyMessage)
|
||||||
|
|
||||||
this.olVRoots.forEach(rt => rt.applyChanges())
|
this.olVRoots.forEach(rt => rt.applyChanges())
|
||||||
// Thinkabout (read): css preload
|
// Thinkabout (read): css preload
|
||||||
// What if we go back before it is ready? We'll have two handlres?
|
// What if we go back before it is ready? We'll have two handlres?
|
||||||
return this.stylesManager.moveReady(t).then(() => {
|
return this.stylesManager.moveReady().then(() => {
|
||||||
/* Waiting for styles to be applied first */
|
/* Waiting for styles to be applied first */
|
||||||
/* Applying focus */
|
/* Applying focus */
|
||||||
this.focusManager.move(t)
|
this.focusManager.move(t)
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@ export default class StylesManager {
|
||||||
private linkLoadingCount: number = 0;
|
private linkLoadingCount: number = 0;
|
||||||
private linkLoadPromises: Array<Promise<void>> = [];
|
private linkLoadPromises: Array<Promise<void>> = [];
|
||||||
private skipCSSLinks: Array<string> = []; // should be common for all pages
|
private skipCSSLinks: Array<string> = []; // should be common for all pages
|
||||||
|
private abortController = new AbortController()
|
||||||
|
|
||||||
constructor(private readonly screen: Screen, private readonly setLoading: (flag: boolean) => void) {}
|
constructor(private readonly screen: Screen, private readonly setLoading: (flag: boolean) => void) {}
|
||||||
|
|
||||||
|
|
@ -25,17 +26,26 @@ export default class StylesManager {
|
||||||
this.linkLoadingCount = 0;
|
this.linkLoadingCount = 0;
|
||||||
this.linkLoadPromises = [];
|
this.linkLoadPromises = [];
|
||||||
|
|
||||||
//cancel all promises? thinkaboutit
|
this.abortController.abort();
|
||||||
|
this.abortController = new AbortController();
|
||||||
}
|
}
|
||||||
|
|
||||||
setStyleHandlers(node: HTMLLinkElement, value: string): void {
|
setStyleHandlers(node: HTMLLinkElement, value: string): void {
|
||||||
let timeoutId: ReturnType<typeof setTimeout> | undefined;
|
let timeoutId: ReturnType<typeof setTimeout> | undefined;
|
||||||
const promise = new Promise<void>((resolve) => {
|
const promise = new Promise<void>((resolve) => {
|
||||||
if (this.skipCSSLinks.includes(value)) resolve();
|
if (
|
||||||
this.linkLoadingCount++;
|
this.abortController.signal.aborted
|
||||||
|
|| this.skipCSSLinks.includes(value)
|
||||||
|
|| node.ownerDocument !== this.screen.document
|
||||||
|
) {
|
||||||
|
console.log('skipped', node, value, this.abortController.signal.aborted, this.skipCSSLinks.includes(value), node.ownerDocument !== this.screen.document)
|
||||||
|
resolve();
|
||||||
|
}
|
||||||
this.setLoading(true);
|
this.setLoading(true);
|
||||||
const addSkipAndResolve = () => {
|
this.linkLoadingCount++;
|
||||||
|
const addSkipAndResolve = (e: any) => {
|
||||||
this.skipCSSLinks.push(value); // watch out
|
this.skipCSSLinks.push(value); // watch out
|
||||||
|
console.error('skip node', e)
|
||||||
resolve()
|
resolve()
|
||||||
}
|
}
|
||||||
timeoutId = setTimeout(addSkipAndResolve, 4000);
|
timeoutId = setTimeout(addSkipAndResolve, 4000);
|
||||||
|
|
@ -43,23 +53,38 @@ export default class StylesManager {
|
||||||
// It would be better to make it more relyable with addEventListener
|
// It would be better to make it more relyable with addEventListener
|
||||||
node.onload = () => {
|
node.onload = () => {
|
||||||
const doc = this.screen.document;
|
const doc = this.screen.document;
|
||||||
doc && rewriteNodeStyleSheet(doc, node);
|
if (node.ownerDocument === doc && doc) {
|
||||||
|
rewriteNodeStyleSheet(doc, node);
|
||||||
|
}
|
||||||
resolve();
|
resolve();
|
||||||
}
|
}
|
||||||
node.onerror = addSkipAndResolve;
|
node.onerror = addSkipAndResolve;
|
||||||
|
this.abortController.signal.addEventListener('abort', () => {
|
||||||
|
node.onload = null;
|
||||||
|
node.onerror = null;
|
||||||
|
clearTimeout(timeoutId);
|
||||||
|
resolve();
|
||||||
|
});
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
node.onload = null;
|
node.onload = null;
|
||||||
node.onerror = null;
|
node.onerror = null;
|
||||||
clearTimeout(timeoutId);
|
clearTimeout(timeoutId);
|
||||||
this.linkLoadingCount--;
|
this.linkLoadingCount--;
|
||||||
if (this.linkLoadingCount === 0) {
|
if (this.linkLoadingCount === 0) {
|
||||||
this.setLoading(false);
|
setTimeout(() => {
|
||||||
|
this.setLoading(false)
|
||||||
|
this.linkLoadPromises = [];
|
||||||
|
}, 0)
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
this.linkLoadPromises.push(promise);
|
this.linkLoadPromises.push(promise);
|
||||||
}
|
}
|
||||||
|
|
||||||
moveReady(t: number): Promise<void[]> {
|
moveReady(): Promise<void[]> {
|
||||||
return Promise.all(this.linkLoadPromises)
|
if (this.linkLoadingCount > 0) {
|
||||||
|
return Promise.all(this.linkLoadPromises)
|
||||||
|
} else {
|
||||||
|
return Promise.resolve([])
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue