samirkumardas / jmuxer

jMuxer - a simple javascript mp4 muxer that works in both browser and node environment.
Other
549 stars 108 forks source link

fix: release buffer immediately when flushingtime equals 0. #86

Closed janeluck closed 2 years ago

janeluck commented 2 years ago

release buffer as soon as possible when flushingtime equals 0. Heavy throttling of chained JS timers beginning in Chrome 88

samirkumardas commented 2 years ago

Thank you for your time and affords. Apology for the late reply. Here are opinions:

If the purpose is to remove the timer, I would say the solution should be easier. Since the socket event is out of throttling scope, you could use https://github.com/samirkumardas/jmuxer/blob/3a8f6522157f8962cb68e1176ae27788148a4350/src/jmuxer.js#L341 that fires every time when the buffer is added into jMuxer.

  1. You can move the contents of timer callback to a different method and invoke that newly created method inside onBuffer if the flushingTime is zero. In this way, you can use the same method when the timer is on or off. If the timer is on, the said method will be called from timer callback, otherwise, from onBuffer.
  2. The default value of flushingTime should not be 0. Let the user specify it if they want to flush directly without depending on the timer.
  3. You have changed/removed few others things that are not relevant to the timer. Also, the removed part is required for certain cases.
janeluck commented 2 years ago

thank you very much.