Skip to content
This repository has been archived by the owner on Feb 7, 2025. It is now read-only.

Commit

Permalink
Use content-visibility (#320)
Browse files Browse the repository at this point in the history
* perf(frontend): ノートのレンダリングをスキップできるように

* perf(frontend): improve notification rendering performance

* perf(frontend): make skipNoteRender on by default

---------

Co-authored-by: syuilo <[email protected]>
  • Loading branch information
adzukimame and syuilo authored Nov 28, 2024
1 parent 1cb846d commit a1b9786
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 10 deletions.
17 changes: 7 additions & 10 deletions packages/frontend/src/components/MkNote.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ SPDX-License-Identifier: AGPL-3.0-only
v-show="!isDeleted"
ref="rootEl"
v-hotkey="keymap"
:class="[$style.root, { [$style.showActionsOnlyHover]: defaultStore.state.showNoteActionsOnlyHover }]"
:class="[$style.root, { [$style.showActionsOnlyHover]: defaultStore.state.showNoteActionsOnlyHover, [$style.skipRender]: defaultStore.state.skipNoteRender }]"
:tabindex="isDeleted ? '-1' : '0'"
>
<MkNoteSub v-if="appearNote.reply && !renoteCollapsed" :note="appearNote.reply" :class="$style.replyTo"/>
Expand Down Expand Up @@ -167,6 +167,7 @@ import { computed, inject, onMounted, ref, shallowRef, Ref, watch, provide } fro
import * as mfm from 'mfm-js';
import { isPureRenote } from 'misskey-js/note.js';
import type { Note, Clip, NotesTranslateResponse } from 'misskey-js/entities.js';
import type { MenuItem } from '@/types/menu.js';
import MkNoteSub from '@/components/MkNoteSub.vue';
import MkNoteHeader from '@/components/MkNoteHeader.vue';
import MkNoteSimple from '@/components/MkNoteSimple.vue';
Expand Down Expand Up @@ -195,7 +196,6 @@ import { useNoteCapture } from '@/scripts/use-note-capture.js';
import { deepClone } from '@/scripts/clone.js';
import { useTooltip } from '@/scripts/use-tooltip.js';
import { getNoteSummary } from '@/scripts/get-note-summary.js';
import { MenuItem } from '@/types/menu.js';
import MkRippleEffect from '@/components/MkRippleEffect.vue';
import { showMovedDialog } from '@/scripts/show-moved-dialog.js';
import { shouldCollapsed } from '@/scripts/collapsed.js';
Expand Down Expand Up @@ -621,14 +621,6 @@ function emitUpdReaction(emoji: string, delta: number) {
overflow: clip;
contain: content;

// これらの指定はパフォーマンス向上には有効だが、ノートの高さは一定でないため、
// 下の方までスクロールすると上のノートの高さがここで決め打ちされたものに変化し、表示しているノートの位置が変わってしまう
// ノートがマウントされたときに自身の高さを取得し contain-intrinsic-size を設定しなおせばほぼ解決できそうだが、
// 今度はその処理自体がパフォーマンス低下の原因にならないか懸念される。また、被リアクションでも高さは変化するため、やはり多少のズレは生じる
// 一度レンダリングされた要素はブラウザがよしなにサイズを覚えておいてくれるような実装になるまで待った方が良さそう(なるのか?)
//content-visibility: auto;
//contain-intrinsic-size: 0 128px;

&:focus-visible {
outline: none;

Expand Down Expand Up @@ -689,6 +681,11 @@ function emitUpdReaction(emoji: string, delta: number) {
}
}

.skipRender {
content-visibility: auto;
contain-intrinsic-size: 0 150px;
}

.tip {
display: flex;
align-items: center;
Expand Down
2 changes: 2 additions & 0 deletions packages/frontend/src/components/MkNotification.vue
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,8 @@ function getActualReactedUsersCount(notification: Notification) {
overflow-wrap: break-word;
display: flex;
contain: content;
content-visibility: auto;
contain-intrinsic-size: 0 100px;

--eventFollow: #36aed2;
--eventRenote: #36d298;
Expand Down
16 changes: 16 additions & 0 deletions packages/frontend/src/pages/settings/other.vue
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,17 @@ SPDX-License-Identifier: AGPL-3.0-only
</div>
</MkFolder>

<MkFolder>
<template #icon><i class="ti ti-flask"></i></template>
<template #label>{{ i18n.ts.experimentalFeatures }}</template>

<div class="_gaps_m">
<MkSwitch v-model="skipNoteRender">
<template #label>Enable note render skipping</template>
</MkSwitch>
</div>
</MkFolder>

<MkFolder>
<template #icon><i class="ti ti-code"></i></template>
<template #label>{{ i18n.ts.developer }}</template>
Expand Down Expand Up @@ -82,9 +93,14 @@ import FormSection from '@/components/form/section.vue';

const $i = signinRequired();

const skipNoteRender = computed(defaultStore.makeGetterSetter('skipNoteRender'));
const devMode = computed(defaultStore.makeGetterSetter('devMode'));
const defaultWithReplies = computed(defaultStore.makeGetterSetter('defaultWithReplies'));

watch(skipNoteRender, async () => {
await reloadAsk({ reason: i18n.ts.reloadToApplySetting, unison: true });
});

async function deleteAccount() {
{
const { canceled } = await os.confirm({
Expand Down
4 changes: 4 additions & 0 deletions packages/frontend/src/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,10 @@ export const defaultStore = markRaw(new Storage('base', {
where: 'device',
default: 'app' as 'app' | 'appWithShift' | 'native',
},
skipNoteRender: {
where: 'device',
default: true,
},

sound_masterVolume: {
where: 'device',
Expand Down

0 comments on commit a1b9786

Please sign in to comment.