Skip to content

Accessing mode.current causes the derived functions to rerun, which may freeze the browser if there are too many of them #126

@SeanIsTyping

Description

@SeanIsTyping

Describe the bug

I'm actually not sure if this is a Svelte or mode-watcher issue.

It seems like under certain circumstances, simply accessing mode.current can trigger the derived function of it, and since that might call withoutTransition (which force the browser to repaint), the browser may freeze if there are a bunch of them on the page.

Setting disableTransition to false so that withoutTransition is not called can make things a lot better, but since there is still a document.querySelector in update, which is not really cheap if the page is complex, it might still slow down the page.

Might be related to sveltejs/svelte#15414

Reproduction

https://stackblitz.com/edit/vitejs-vite-aapsdita?file=src%2FApp.svelte

Logs

System Info

System:
    OS: Linux 5.0 undefined
    CPU: (8) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
    Memory: 0 Bytes / 0 Bytes
    Shell: 1.0 - /bin/jsh
  Binaries:
    Node: 20.19.1 - /usr/local/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 10.8.2 - /usr/local/bin/npm
    pnpm: 8.15.6 - /usr/local/bin/pnpm
  npmPackages:
    mode-watcher: ^1.0.2 => 1.0.2 
    svelte: ^5.28.1 => 5.28.2

Severity

annoyance

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions