Updates based on preload branch - #1413
Closed
peaBerberian wants to merge 9 commits into
Closed
Conversation
peaBerberian
force-pushed
the
misc/updates-based-on-preload
branch
from
May 2, 2024 14:44
73af7b5 to
9e5ac7b
Compare
peaBerberian
force-pushed
the
misc/updates-based-on-preload
branch
2 times, most recently
from
June 17, 2024 16:45
322c7ec to
503b4ef
Compare
peaBerberian
force-pushed
the
misc/updates-based-on-preload
branch
2 times, most recently
from
June 28, 2024 14:46
89f791b to
5a50ac5
Compare
peaBerberian
force-pushed
the
misc/updates-based-on-preload
branch
2 times, most recently
from
July 31, 2024 09:05
1d5d05e to
04af06c
Compare
peaBerberian
force-pushed
the
misc/updates-based-on-preload
branch
from
August 5, 2024 12:21
04af06c to
828864c
Compare
peaBerberian
force-pushed
the
misc/updates-based-on-preload
branch
3 times, most recently
from
September 4, 2024 18:20
f1abae4 to
c8b7b1d
Compare
We changed the name of classes from *SegmentBuffer to *SegmentSink but didn't actually update the file names. This is now done.
To avoid the confusion between several concepts named "settings" in the `MediaSourceContentInitializer`, the settings provided to its constructor is now renamed to `_initSettings` (aligns with `_initCanceller` for its TaskCanceller initialized at instantiation).
Some private methods of the `MediaSourceContentInitializer` were difficult to follow due to the heavy usage of inner functions with unclear names (such as `recursivelyLoadOnMediaSource`). I now tried to isolate some of those and rename the different methods called at content load so it makes more sense. Methods in order are: ``` start > _setupInitialMediaSourceAndDecryption > _onInitialMediaSourceReady > _setupContentWithNewMediaSource > _startLoadingContentOnMediaSource ``` Note: `_setupContentWithNewMediaSource` and `_startLoadingContentOnMediaSource` are still similarly named, though the former just has the task of setting up a reloading logic and then calling the latter. Note2: `_startLoadingContentOnMediaSource` is still a huge and complex method that we might improve on in the future.
This is a minor code update to make the NativeTextDisplayer's clean-up easier to follow by isolating the DOM-related (TextTrack, HTMLTrackElement, HTMLMediaElement) code inside its own private method.
…ctions The callback called on the `"updateend"` and `"error"` events on a SourceBuffer were previously declared as arrow functions inside the constructor. This allowed to keep a clear JS context for the `this` keyword, but it made the `MainSourceBufferInterface`'s constructor harder to read. I found it more readable to declare both callback as private methods instead, with the drawback of having to bind the `this` explictely.
Our `SyncOrAsync` util is used for cases where a task is >99% of the time synchronous, yet <1% of the time asynchronous, and where we don't want to incur any overhead/supplementary complexity of awaiting a Promise which inherently schedule a microtask when the value is most probably already there. It worked well for most usages, but it turns out that a task that starts as asynchronous would then always lead to the need to rely on Promises, even once the task is finished (basically, if it started as an "async value" it could never transform itself to a "sync value"). This does not create any issue but we could gain some minuscule advantage (well, we could argue that `SyncOrAsync`'s advantage is in itself minuscule) here by just relying on the value synchronously once the task is finished.
peaBerberian
force-pushed
the
misc/updates-based-on-preload
branch
from
October 8, 2024 15:12
c8b7b1d to
f88e5fd
Compare
This was referenced Oct 8, 2024
This was referenced Oct 8, 2024
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The last preload branch (#1407) is a good start for a preload API but is not yet finished and is already getting very big.
I noticed when working on it that several code updates made sense even without the Preload API.
So I decided to isolate those parts in a separate PR, where each commit details one type of update. The main theme is improving code readability:
Rename segment_buffer file into the new segment_sink name
We changed the name of classes from SegmentBuffer to SegmentSink but
didn't actually update the file names. This is now done.
Rely on compat version of TextTrack-related types in remove_cue.ts
Provide more precize typing for the SegmentSinksStore's SegmentSinks
ContentInit: Rename "settings" into "initSettings"
To avoid the confusion between several concepts named "settings" in the
MediaSourceContentInitializer, the settings provided to itsconstructor is now renamed to
_initSettings(aligns with_initCancellerfor its TaskCanceller initialized at instantiation).Rename and factorize some methods of the MediaSourceContentInitializer
Some private methods of the
MediaSourceContentInitializerweredifficult to follow due to the heavy usage of inner functions with
unclear names (such as
recursivelyLoadOnMediaSource).I now tried to isolate some of those and rename the different methods
called at content load so it makes more sense. Methods in order are:
Note:
_setupContentWithNewMediaSourceand_startLoadingContentOnMediaSourceare still similarly named, thoughthe former just has the task of setting up a reloading logic and then
calling the latter.
Note2:
_startLoadingContentOnMediaSourceis still a huge and complexmethod that we might improve on in the future.
Isolate HTMLTrackElement clearing in its own private method
This is a minor code update to make the NativeTextDisplayer's clean-up
easier to follow by isolating the DOM-related (TextTrack,
HTMLTrackElement, HTMLMediaElement) code inside its own private method.
Make MainSourceBufferInterface code more readable isolating inner functions
The callback called on the
"updateend"and"error"events on aSourceBuffer were previously declared as arrow functions inside the
constructor.
This allowed to keep a clear JS context for the
thiskeyword, but itmade the
MainSourceBufferInterface's constructor harder to read.I found it more readable to declare both callback as private methods
instead, with the drawback of having to bind the
thisexplictely.Fix SyncOrAsync util syncValue transfer
Our
SyncOrAsyncutil is used for cases where a task is >99% of the timesynchronous, yet <1% of the time asynchronous, and where we don't want to
incur any overhead/supplementary complexity of awaiting a Promise which
inherently schedule a microtask when the value is most probably already
there.
It worked well for most usages, but it turns out that a task that starts
as asynchronous would then always lead to the need to rely on Promises,
even once the task is finished (basically, if it started as an "async
value" it could never transform itself to a "sync value").
This does not create any issue but we could gain some minuscule advantage
(we could argue that
SyncOrAsync's advantage is in itselfminuscule) here by just relying on the value synchronously once the task is
finished.