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(mux-video,mux-audio): reload core on DOM connect #765

Merged
merged 3 commits into from
Sep 5, 2023

Conversation

cjpillsbury
Copy link
Contributor

@cjpillsbury cjpillsbury commented Sep 5, 2023

Currently, we do an "unload"/teardown of core (and everything that happens in it/is created by it "under the hood") whenever our custom media elements are disconnected from the DOM. Ideally, this would not be the way we handle cleanups, as we're currently treating disconnect as a "destroy()" method. This causes issues with more advanced UIs/use cases, especially common in app frameworks where an element may be moved around the DOM for UI/UX purposes without the intention of destroying it. Unfortunately, it looks like we have some dangling references that result in a fairly large memory footprint per media element if we don't do this teardown. As a "middle ground" solution until we can identify a reasonable and reliable resolution of this larger memory management GC issue, we will simply (conditionally) "reload"/re-initialize core when the media element is (re)connected to the DOM.

@cjpillsbury cjpillsbury requested a review from a team as a code owner September 5, 2023 13:21
@vercel
Copy link

vercel bot commented Sep 5, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
elements-demo-create-react-app ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 5, 2023 1:56pm
elements-demo-nextjs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 5, 2023 1:56pm
elements-demo-svelte-kit ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 5, 2023 1:56pm
elements-demo-vanilla ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 5, 2023 1:56pm
elements-demo-vue ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 5, 2023 1:56pm

@codecov
Copy link

codecov bot commented Sep 5, 2023

Codecov Report

Merging #765 (ef382bb) into main (46b3b81) will increase coverage by 0.05%.
The diff coverage is 100.00%.

❗ Current head ef382bb differs from pull request most recent head b485ec6. Consider uploading reports for the commit b485ec6 to get more accurate results

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #765      +/-   ##
==========================================
+ Coverage   82.12%   82.18%   +0.05%     
==========================================
  Files          40       40              
  Lines        7848     7862      +14     
  Branches      458      456       -2     
==========================================
+ Hits         6445     6461      +16     
+ Misses       1397     1395       -2     
  Partials        6        6              
Files Changed Coverage Δ
packages/mux-audio/src/index.ts 68.98% <100.00%> (+0.80%) ⬆️
packages/mux-video/src/index.ts 68.57% <100.00%> (+0.51%) ⬆️

@AdamJaggard
Copy link
Contributor

Unrelated to code, the title needs a : instead of a / 🙃

Copy link
Contributor

@AdamJaggard AdamJaggard left a comment

Choose a reason for hiding this comment

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

LGTM. Obviously not ideal but does the job and hopefully in the general case people aren't constantly disconnecting and re-connecting their components.

@cjpillsbury
Copy link
Contributor Author

Unrelated to code, the title needs a : instead of a / 🙃

Yeah that's derived from my branch name, not my intended squash commit msg. That said, since we've moved to squash merges instead of rebase merges, I've def unintentionally merged with the wrong commit msg before.

@cjpillsbury cjpillsbury merged commit 3b61394 into muxinc:main Sep 5, 2023
4 checks passed
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