Skip to content

Commit

Permalink
fix(edgeless): large frame crash on ios safari (#8877)
Browse files Browse the repository at this point in the history
  • Loading branch information
doodlewind authored Dec 6, 2024
1 parent 07d7918 commit 8a1243b
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions packages/blocks/src/frame-block/frame-block.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import type { FrameBlockModel } from '@blocksuite/affine-model';

import { ThemeProvider } from '@blocksuite/affine-shared/services';
import { GfxBlockComponent } from '@blocksuite/block-std';
import { Bound } from '@blocksuite/global/utils';
import { cssVarV2 } from '@toeverything/theme/v2';
import { html } from 'lit';
import { state } from 'lit/decorators.js';
Expand All @@ -24,6 +25,38 @@ export class FrameBlockComponent extends GfxBlockComponent<FrameBlockModel> {
}
})
);
this._disposables.add(
this.gfx.viewport.viewportUpdated.on(() => {
this.requestUpdate();
})
);
}

/**
* Due to potentially very large frame sizes, CSS scaling can cause iOS Safari to crash.
* To mitigate this issue, we combine size calculations within the rendering rect.
*/
override getCSSTransform(): string {
return '';
}

override getRenderingRect() {
const viewport = this.gfx.viewport;
const { translateX, translateY, zoom } = viewport;
const { xywh, rotate } = this.model;
const bound = Bound.deserialize(xywh);

const scaledX = bound.x * zoom + translateX;
const scaledY = bound.y * zoom + translateY;

return {
x: scaledX,
y: scaledY,
w: bound.w * zoom,
h: bound.h * zoom,
rotate,
zIndex: this.toZIndex(),
};
}

override renderGfxBlock() {
Expand Down

0 comments on commit 8a1243b

Please sign in to comment.