-
Notifications
You must be signed in to change notification settings - Fork 6k
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
Cea608Decoder Span parameter Crash #4321
Comments
we saw the same issue and we had to add length checks in all setSpan() calls in cea608Decoder.java and cea708decoder.java |
The person who wrote this code no longer works on the project, however looking at the corresponding code review, it appears the intention is to handle the white-italic case, where two spans are used to apply a single style: The nextStyleIncrement ensures both of the corresponding spans are ended at the correct position (ignoring other bugs that might make this statement untrue ;)).
I don't know enough about the spec to answer this, except to say that the comments in the code suggest not. Are you seeing visible issues that would be resolved by doing this?
Are you sure cascading spans are added? It looks to me like spans have their end points calculated when they're added: Which seems like pretty much the same thing as you're describing... Although perhaps it's a bug that
I think so, yes. In summary, I think there are a few issues here:
Does that seem plausible to you? I can open a pull request with some proposed fixes (although I probably wont be able to test them that thoroughly; that would be your job ;)). |
Do you have any good test content for demonstrating these issues? |
Most crashes were identified by just leaving a local live channel play overnight (any channel that should also be available in the Mountain View area). I usually test the code including all these changes as well: #4308 (and much more, but the caption features can be usually separated from other changes). If the change is more-or-less merge-able onto the head of the pull request, I can probably test them. |
A further thought about this: It seems problematic that, if we were to do this, there's a way to return to "default color" whilst also changing to italic, but not otherwise (i.e. non-italic). It kind of suggests we should treat WHITE as "default color" too, although that is in itself slightly strange. Alternatively, we could make all 608 captions explicitly white. Hmm! |
You are right, the mid-row spans are using this nextStyleIncrement values I do not fully get yet. But as I see, at least the midrow spans are inside the preamble spans, aren't they? About Default color: My original Pull request for ExoV1 handled white as "default color" everywhere. So instead of opening a new color span for white, I simply closed the previous color span. The ExoV2 caption handling shows lots of similarities, but this part was not kept: About the nextStyleIncrement the 608 standard has priorities for the formatting: https://www.law.cornell.edu/cfr/text/47/79.101
So I implemented it by closing previous spans in order of the priorities, so there was no way to create an invalid order. I did not use 2 list of spans, one for collecting the preamble and one for the mid-row styling. My version used the theoretical limitation that there can be only 3 spans open at any time: one color, one underline and one italic. The current HEAD seems to have a list for MidRowStyle-s, and whenever we add a new style (start a new span) we also save new nextStyleIncrement values so we know which "next start span opening position" to use to close this current span? ExoPlayer/library/core/src/main/java/com/google/android/exoplayer2/text/cea/Cea608Decoder.java Line 706 in 2b20780
Might be correct, but hard to interpret that it works as intended. |
Issue: #4321 ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=202660712
This should be fixed by the change above, although we've yet to acquire test streams that allow us to thoroughly test the change. Please verify. |
@ojw28 I'm still able to reproduce this on 2.8.2. Here's a simple 3-segment manifest that will repro: https://static-us-east-2-fastly-a.www.philo.com/storage/cea608-exo-bug/manifest.mpd My naive solution would be to check that |
@baconz - The fix hasn't made it into a release yet, so that's expected. Thanks for the sample, that's really helpful. I can confirm that the failure does not occur with this sample in our |
Issue: #4321 ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=202660712
@ojw28 sorry, I missed that! I saw mentions of CEA-608 improvements in the 2.8.2, and didn't bother to check if they were these improvements. Let me know if I can further assist in testing, or if you have any questions about the content I posted. |
This line tends to crash quite often for live content:
ExoPlayer/library/core/src/main/java/com/google/android/exoplayer2/text/cea/Cea608Decoder.java
Line 708 in 2b55c91
I had a pull request for handling the various styles in Cea608Decoders for ExoPlayer 1. For ExoPlayer 2, you have included many parts of that pull request, but you also re-designed the handling of the styles by adding the CueStyle class. So my understanding of the CueStyle might be different than yours.
This current code creates list of CueStyles, and adds them only when the captions are rendered. I could identify one case when this current solution crashes. Incoming caption bytes are:
The crash itself is:
(As the line numbers suggest, we have some modifications in Cea608Decoder that is not shared (yet), but the crash should be present irrespective of our changes.)
The issue seems to be the independent handling of the characters and the spans: backspace should be able to clear any characters and possibly create empty spans as well. This list of Spans applied right before rendering seems to be a fragile solution. In this specific case leading to the crash, turning on ITALIC adds two items to the span list:
ExoPlayer/library/core/src/main/java/com/google/android/exoplayer2/text/cea/Cea608Decoder.java
Lines 384 to 385 in 2b20780
Then comes a BackSpace command and our indices become invalid.
The crash can be avoided simply be checking the validity of the Span indices for the current content of the StringBuilder. Although it is hard to prove that the intention of the caption provider was matching the rendered result. I have a few question:
The text was updated successfully, but these errors were encountered: