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

Double texture freeing bug #529

Closed
philippe-wm opened this issue Apr 5, 2024 · 0 comments · Fixed by #538 or #540
Closed

Double texture freeing bug #529

philippe-wm opened this issue Apr 5, 2024 · 0 comments · Fixed by #538 or #540

Comments

@philippe-wm
Copy link

philippe-wm commented Apr 5, 2024

Issue

We found that Lightning occasionally tries to double-release textures.

The problem is that when freeing a texture, this updates the Stage total used memory:
https://github.com/rdkcentral/Lightning/blob/dev/src/tree/TextureManager.mjs#L164

Unfortunately ANY total memory usage update can cause an immediate GC:
https://github.com/rdkcentral/Lightning/blob/dev/src/tree/Stage.mjs#L452

This can cause a race condition where a texture release can cause a GC run re-releasing the texture before it has finished the initial release.

Workaround

Prevent Stage to run GC when updating the total memory with a negative delta:

const _addMemoryUsage = stage.addMemoryUsage;
stage.addMemoryUsage = (delta) => {
  if (delta < 0) {
    stage._usedMemory += delta;
  } else {
    _addMemoryUsage.apply(stage, [delta]);
  }
};

Possibly related issues: #492, #520, #521

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 a pull request may close this issue.

1 participant