Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: dev-tools only set monaco model and text when changing #2417

Merged
merged 1 commit into from
Jul 19, 2024
Merged

fix: dev-tools only set monaco model and text when changing #2417

merged 1 commit into from
Jul 19, 2024

Conversation

HollowMan6
Copy link
Contributor

The basics

The details

Resolves

Fixes:

Proposed Changes

This commit introduces a workaround, so that we only update the page when we have model or text updates in monaco.

Reason for Changes

In multi-select plugin, a significant amount of workspace change events (for each block) can be triggered at the same time, which causes the garbage collection mechanism to fail, so that we eventually have JS heap overflow and the page crashed in Chromium.

Test Coverage

Documentation

Additional Information

@HollowMan6 HollowMan6 requested a review from a team as a code owner July 11, 2024 17:57
@HollowMan6 HollowMan6 requested review from cpcallen and removed request for a team July 11, 2024 17:57
@HollowMan6 HollowMan6 changed the title dev-tools: Only set monaco model and text when changing fix: dev-tools only set monaco model and text when changing Jul 11, 2024
Context:
- mit-cml/workspace-multiselect#62 (comment)
- mit-cml/workspace-multiselect#62 (comment)
- mit-cml/workspace-multiselect#62 (comment)

In multi-select plugin, a significant amount of workspace
change events (for each block) can be triggered at the same
time, which causes the garbage collection mechanism to fail,
so that we eventually have JS heap overflow and the page
crashed in Chromium.

This commit introduces a workaround for this, so that we only
update the page when we have model or text updates in monaco.

Signed-off-by: Hollow Man <hollowman@opensuse.org>
Copy link
Contributor

@cpcallen cpcallen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi HollowMan6. Interesting situation.

Is there a bug open against Monaco and/or Chrome for this apparent garbage collection failure?

The workaround code seems perfectly reasonable but I would want it to be documented with reference to a bug so that it can be removed when the bug is fixed.

@HollowMan6
Copy link
Contributor Author

Hi @cpcallen! Thanks for taking a look at this PR.

Is there a bug open against Monaco and/or Chrome for this apparent garbage collection failure?

No, I haven't filed a bug about this, and I guess this might not even be qualified as a "bug" on their side, as I saw that we update the editor with the same text almost 30 times at the same time when that garbage collection fails, which is unreasonable.

The workaround code seems perfectly reasonable but I would want it to be documented with reference to a bug so that it can be removed when the bug is fixed.

Actually, I think it might be a good idea to have this workaround code even if the bug is fixed somehow, as we don't need to disturb the editor if the text and model are unchanged (so this might even improve the performance).

@cpcallen
Copy link
Contributor

Is there a bug open against Monaco and/or Chrome for this apparent garbage collection failure?

No, I haven't filed a bug about this, and I guess this might not even be qualified as a "bug" on their side, as I saw that we update the editor with the same text almost 30 times at the same time when that garbage collection fails, which is unreasonable.

I'd grant you that it is foolish, but the it is the crash which is unreasonable. Either there is:

  1. a GC failure in Chrome (bug!), or
  2. a memory leak in Monaco (bug!), or
  3. Monaco is for some reason keeping old copies of the text being edited around for some non-obvious reason (documentation bug?)

Especially if this does not occur in Firefox then it seems like it is probably 1 (and certainly not 3), so I think this deserves to be reported upstream. Maybe reporting it to Monaco in the first instance, and let them report it upstream?

Nevertheless…

Actually, I think it might be a good idea to have this workaround code even if the bug is fixed somehow, as we don't need to disturb the editor if the text and model are unchanged (so this might even improve the performance).

Upon reflection I agree with you about this.

@cpcallen cpcallen merged commit 20be3a3 into google:master Jul 19, 2024
7 checks passed
@HollowMan6
Copy link
Contributor Author

HollowMan6 commented Jul 19, 2024

Sure, I will file a bug report to monaco first.

  1. a memory leak in Monaco (bug!), or
  2. Monaco is for some reason keeping old copies of the text being edited around for some non-obvious reason (documentation bug?)

Edit: Monaco asks to reproduce the bug in the playground, but it seems like I can't reproduce it anyway in their playground (only see heap size surges but drops quickly), so it shouldn't be 2 and 3.

So I think it's more related to Chrome or even V8 JavaScript engine, about their memory management, when computing performance drops (e.g. with heavy rendering load), the garbage collection fails to start, file a Chrome issue should be a proper choice.

https://microsoft.github.io/monaco-editor/playground.html?source=v0.50.0#XQAAAAI9RwAAAAAAAABBqQkHQ5NjdMjwa-jY7SIQ9S7DNlzs5W-mwj0fe1ZCDRFc9ws9XQE0SJE1jc2VKxhaLFIw9v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gAjj_sndhv2BbzETkJYzhxyD8I-EAyxkd2YSbKx5JkdUZc10LNEjErE5iAbxJYtU2NZ-a1PBHAG6-bjNYZm_C_-1mwJo6UWqLsRQUVDs86QKJyEtbdVh1e7KzW0GvskRzwGPJff_LwQJv0AGu8cSYpqauD_ByDwMnKDgeB13zxDwcYG_5gqmxxaYHGYAKWb8k50TYyBflQQoS5oap0-a5Rfsm2MsHGLlm_MPdZHJjUuic1apch5tQb5qM_F8HIEN4986qUaTKPTP1wTm-_YNo-Qr1-VPSPJMv4zbQ5uon8I8c4Sgdq_FLmiJTrneVr4x3sY_EXpiHE9Xjfm6HDNet4Chc0CiNs8YblIunu8EPc-WvtMHAE-iNza33CzLnP6_80ko6bKOuRnlERZMgMQ0NoffQb8Bz2YkdgGRHPgCRkdSfPXoq35OEnvSNJCOAQ5K2hDfEVpYG9r2wRceMoPXxJ_TdrHtirxgaf-rdCDz1cy0hhWpwVxfGzC_Zbtm_16oFWXKzwtnR_S03_95ot8A

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants