fix ui: fix chrome crash code11

This commit is contained in:
nick-delirium 2024-04-24 14:17:38 +02:00
parent 49e35cb329
commit 04240ce9b3
No known key found for this signature in database
GPG key ID: 93ABD695DF5FDBA0
4 changed files with 35 additions and 12 deletions

View file

@ -274,9 +274,9 @@ export default class MessageManager {
public changeTab(tabId: string) {
this.activeTab = tabId;
this.state.update({ currentTab: tabId });
this.tabs[tabId].clean();
this.tabs[tabId].move(this.state.get().time);
this.state.update({ currentTab: tabId });
}
public updateChangeEvents() {

View file

@ -342,7 +342,6 @@ export default class TabSessionManager {
Object.assign(stateToUpdate, this.lists.moveGetState(t));
Object.keys(stateToUpdate).length > 0 && this.updateLocalState(stateToUpdate);
/* Sequence of the managers is important here */
// Preparing the size of "screen"
const lastResize = this.resizeManager.moveGetLast(t, index);

View file

@ -422,11 +422,10 @@ export default class DOMManager extends ListWalker<Message> {
*/
async moveReady(t: number): Promise<void> {
this.moveApply(t, this.applyMessage)
this.olVRoots.forEach(rt => rt.applyChanges())
// Thinkabout (read): css preload
// 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 */
/* Applying focus */
this.focusManager.move(t)

View file

@ -18,6 +18,7 @@ export default class StylesManager {
private linkLoadingCount: number = 0;
private linkLoadPromises: Array<Promise<void>> = [];
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) {}
@ -25,17 +26,26 @@ export default class StylesManager {
this.linkLoadingCount = 0;
this.linkLoadPromises = [];
//cancel all promises? thinkaboutit
this.abortController.abort();
this.abortController = new AbortController();
}
setStyleHandlers(node: HTMLLinkElement, value: string): void {
let timeoutId: ReturnType<typeof setTimeout> | undefined;
const promise = new Promise<void>((resolve) => {
if (this.skipCSSLinks.includes(value)) resolve();
this.linkLoadingCount++;
if (
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);
const addSkipAndResolve = () => {
this.linkLoadingCount++;
const addSkipAndResolve = (e: any) => {
this.skipCSSLinks.push(value); // watch out
console.error('skip node', e)
resolve()
}
timeoutId = setTimeout(addSkipAndResolve, 4000);
@ -43,23 +53,38 @@ export default class StylesManager {
// It would be better to make it more relyable with addEventListener
node.onload = () => {
const doc = this.screen.document;
doc && rewriteNodeStyleSheet(doc, node);
if (node.ownerDocument === doc && doc) {
rewriteNodeStyleSheet(doc, node);
}
resolve();
}
node.onerror = addSkipAndResolve;
this.abortController.signal.addEventListener('abort', () => {
node.onload = null;
node.onerror = null;
clearTimeout(timeoutId);
resolve();
});
}).then(() => {
node.onload = null;
node.onerror = null;
clearTimeout(timeoutId);
this.linkLoadingCount--;
if (this.linkLoadingCount === 0) {
this.setLoading(false);
setTimeout(() => {
this.setLoading(false)
this.linkLoadPromises = [];
}, 0)
}
});
this.linkLoadPromises.push(promise);
}
moveReady(t: number): Promise<void[]> {
return Promise.all(this.linkLoadPromises)
moveReady(): Promise<void[]> {
if (this.linkLoadingCount > 0) {
return Promise.all(this.linkLoadPromises)
} else {
return Promise.resolve([])
}
}
}