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

Crash when certain video previews are loaded: video title has an unexpected char #5943

Closed
3 tasks done
DanielProg39 opened this issue Apr 30, 2024 · 18 comments · Fixed by TeamPiped/piped-proxy#178
Closed
3 tasks done
Labels
bug Something isn't working can't reproduce

Comments

@DanielProg39
Copy link

Steps to reproduce

What I did:

  1. Opened one of my playlists
  2. Scrolled down
  3. When the app supposedly loaded the video called "Explaining why this chessboard puzzle is impossible without n² squares (solution in description)", the app crashed and the next time it was opened it showed an error.

Expected behavior

The app should process all symbols without problems.

Actual behavior

Application crashes when loading "²" character.

LibreTube version

LibreTube Debug, commit 51cc630

Android version

Android 13

Other details

Error message:

java.lang.IllegalArgumentException: Unexpected char 0xfffd at 61 in x-title value: Explaining why this chessboard puzzle is impossible without n� squares (solution in description)
	at okhttp3.Headers$Companion.checkValue(Headers.kt:450)
	at okhttp3.Headers$Companion.access$checkValue(Headers.kt:362)
	at okhttp3.Headers$Builder.add(Headers.kt:261)
	at okhttp3.Response$Builder.addHeader(Response.kt:376)
	at com.google.net.cronet.okhttptransport.ResponseConverter.toResponse(ResponseConverter.java:128)
	at com.google.net.cronet.okhttptransport.RequestResponseConverter$1.getResponse(RequestResponseConverter.java:124)
	at com.google.net.cronet.okhttptransport.RequestResponseConverter$CronetRequestAndOkHttpResponse.getResponse(RequestResponseConverter.java:156)
	at com.google.net.cronet.okhttptransport.CronetInterceptor.intercept(CronetInterceptor.java:109)
	at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
	at okhttp3.internal.connection.RealCall.getResponseWithInterceptorChain$okhttp(RealCall.kt:201)
	at okhttp3.internal.connection.RealCall$AsyncCall.run(RealCall.kt:517)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1137)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:637)
	at java.lang.Thread.run(Thread.java:1012)
    

Acknowledgements

  • I have searched the existing issues and this is a new ticket, NOT a duplicate or related to another open issue.
  • I have written a short but informative title.
  • I will fill out all of the requested information in this form.
@DanielProg39 DanielProg39 added the bug Something isn't working label Apr 30, 2024
@Bnyro
Copy link
Member

Bnyro commented Apr 30, 2024

What's the videoId of the video to reproduce the crash? I can't find it by searching the title.

@DanielProg39
Copy link
Author

wTJI_WuZSwE - but it seems that the title has changed since I added the video to my playlist, but in the playlist the title remains the same.

However, you can reproduce the error by pasting "Explaining why this chessboard puzzle is impossible without n² squares (solution in description)" in the search bar in the app. Application then crashes and upon restart it shows this error:

java.lang.IllegalArgumentException: Unexpected char 0xfffd at 61 in x-title value: Explaining why this chessboard puzzle is impossible without n� squares (solution in description)
	at okhttp3.Headers$Companion.checkValue(Headers.kt:450)
	at okhttp3.Headers$Companion.access$checkValue(Headers.kt:362)
	at okhttp3.Headers$Builder.add(Headers.kt:261)
	at okhttp3.Response$Builder.addHeader(Response.kt:376)
	at com.google.net.cronet.okhttptransport.ResponseConverter.toResponse(ResponseConverter.java:128)
	at com.google.net.cronet.okhttptransport.RequestResponseConverter$1.getResponse(RequestResponseConverter.java:124)
	at com.google.net.cronet.okhttptransport.RequestResponseConverter$CronetRequestAndOkHttpResponse.getResponse(RequestResponseConverter.java:156)
	at com.google.net.cronet.okhttptransport.CronetInterceptor.intercept(CronetInterceptor.java:109)
	at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
	at okhttp3.internal.connection.RealCall.getResponseWithInterceptorChain$okhttp(RealCall.kt:201)
	at okhttp3.internal.connection.RealCall$AsyncCall.run(RealCall.kt:517)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1137)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:637)
	at java.lang.Thread.run(Thread.java:1012)
    

@DanielProg39
Copy link
Author

Further diving into the problem, I tried to find videos with "²" character in them. Pasting "n²" and other variations didn't lead to any problems, opening videos containing the symbol and adding them to another playlist didn't lead to any crashes and errors either. It seems that the issue is only with that specific title of that video.

Another strange thing is, besides pasting the whole video's title to the search bar, pasting some specific parts of it also lead to the same error, that mentions the whole video's title while the value being pasted is different (being only a part of the title). For example, when I paste "chessboard puzzle is impossible without n² squares", "Explaining why this chessboard puzzle" or even "chessboard puzzle" (which has only two words in it, has way less than 61 characters and by no means contains the "²" character), it leads to this exact error message:

java.lang.IllegalArgumentException: Unexpected char 0xfffd at 61 in x-title value: Explaining why this chessboard puzzle is impossible without n� squares (solution in description)
	at okhttp3.Headers$Companion.checkValue(Headers.kt:450)
	at okhttp3.Headers$Companion.access$checkValue(Headers.kt:362)
	at okhttp3.Headers$Builder.add(Headers.kt:261)
	at okhttp3.Response$Builder.addHeader(Response.kt:376)
	at com.google.net.cronet.okhttptransport.ResponseConverter.toResponse(ResponseConverter.java:128)
	at com.google.net.cronet.okhttptransport.RequestResponseConverter$1.getResponse(RequestResponseConverter.java:124)
	at com.google.net.cronet.okhttptransport.RequestResponseConverter$CronetRequestAndOkHttpResponse.getResponse(RequestResponseConverter.java:156)
	at com.google.net.cronet.okhttptransport.CronetInterceptor.intercept(CronetInterceptor.java:109)
	at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
	at okhttp3.internal.connection.RealCall.getResponseWithInterceptorChain$okhttp(RealCall.kt:201)
	at okhttp3.internal.connection.RealCall$AsyncCall.run(RealCall.kt:517)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1137)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:637)
	at java.lang.Thread.run(Thread.java:1012)
    

Very weird stuff.

@Bnyro
Copy link
Member

Bnyro commented May 1, 2024

I still can't reproduce this with the video and search query you shared, very weird...

@Ganipotes
Copy link

Ganipotes commented May 1, 2024

I had the same problem but when I try to access French YouTube channels.

More precisely, it's the é character that will cause the crash, even if it's in the title of one of the videos of a YouTube channel.

Here some channels that will crash Libretube : Micode, Squeezie, Underscore_, Cyprien

Here one of the logs of the crashes :

java.lang.IllegalArgumentException: Unexpected char 0xfffd at 23 in x-title value: Ne croyez pas cetedite vid�o (Court-m�trage)
	at okhttp3.Headers$Companion.checkValue(SourceFile:87)
	at okhttp3.Headers$Builder.add(SourceFile:14)
	at com.google.net.cronet.okhttptransport.ResponseConverter.toResponse(SourceFile:379)
	at com.google.net.cronet.okhttptransport.CronetInterceptor.intercept(SourceFile:52)
	at okhttp3.internal.http.RealInterceptorChain.proceed(SourceFile:126)
	at okhttp3.internal.connection.RealCall.getResponseWithInterceptorChain$okhttp(SourceFile:97)
	at okhttp3.internal.connection.RealCall$AsyncCall.run(SourceFile:50)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:644)
	at java.lang.Thread.run(Thread.java:1012)

I tried to access the same video as DanielProg39, and it reproduced the same crash for me

@Bnyro Bnyro changed the title Crash when loading the playlist: video title has an unexpected char Crash when certain video previews are loaded: video title has an unexpected char May 5, 2024
@Bnyro
Copy link
Member

Bnyro commented May 5, 2024

The crash log mentions an x-title header - none of the responses from the Piped backend does contain one - code search for x-title: https://github.com/search?q=repo%3ATeamPiped%2FPiped-Backend%20x-title&type=code, same for the proxy.

So what needs to be done is to figure which response actually does send such an X-Title header and then sanitize it at the backend or proxy side.

This could possibly be part of an image response - but I couldn't find any image response returning such a header either. Hence please

  • share the instance used
  • test with the browser debug tools if there's an x-title header returned in any of the responses if navigating on the instance in the web browser

@Bnyro
Copy link
Member

Bnyro commented May 5, 2024

Oh, and can you please enable the data saver mode in the settings and try to reproduce it again? That way we can figure out if the issue is related to the images or the server responses. Looking at coil-kt/coil#1823 which should already be fixed since a while in theory.

@Ganipotes
Copy link

The instance used is adminforge.de

I tried to access the Cyprien channel with also the following instances :
kavin.rocks (Official)
lunar.icu
privacydev.net
smnz.de

They all crash with the same log (that I already shared).

I tried to find out if there was an x-title header like you said, I'm not sure if I looked it right, but I couldn't find it.

But when I tried to reproduce the crash after enabling the data saver mode in the settings :
No crash at all

I tried with 3 instances, and with my french channels and with the DanielProg39 video "Explaining why this chessboard puzzle is impossible without n² squares".
No crash

@s0lid5n4ke
Copy link

Hi, I have the same problem with the instance adminforge.de (German).

It seems that LibreTube has problems with German umlauts like ä or ö.
Maybe an error in the implementation of the UTF-8 encoding?

I will also try to test it in Data Save mode.

type: crash
osVersion: google/husky/husky:14/AP1A.240405.002.B1/2024050300:user/release-keys
package: com.github.libretube:51
process: com.github.libretube
processUptime: 892 + 223 ms
installer: org.fdroid.fdroid

java.lang.IllegalArgumentException: Unexpected char 0xfffd at 30 in x-title value: Wir vertikutieren den Rasen, s�en und d�ngen
	at okhttp3.Headers$Companion.checkValue(SourceFile:87)
	at okhttp3.Headers$Builder.add(SourceFile:14)
	at com.google.net.cronet.okhttptransport.ResponseConverter.toResponse(SourceFile:379)
	at com.google.net.cronet.okhttptransport.CronetInterceptor.intercept(SourceFile:52)
	at okhttp3.internal.http.RealInterceptorChain.proceed(SourceFile:126)
	at okhttp3.internal.connection.RealCall.getResponseWithInterceptorChain$okhttp(SourceFile:97)
	at okhttp3.internal.connection.RealCall$AsyncCall.run(SourceFile:50)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:644)
	at java.lang.Thread.run(Thread.java:1012)

@s0lid5n4ke
Copy link

Hi, I have the same problem with the instance adminforge.de (German).

It seems that LibreTube has problems with German umlauts like ä or ö.
Maybe an error in the implementation of the UTF-8 encoding?

I will also try to test it in Data Save mode.

type: crash
osVersion: google/husky/husky:14/AP1A.240405.002.B1/2024050300:user/release-keys
package: com.github.libretube:51
process: com.github.libretube
processUptime: 892 + 223 ms
installer: org.fdroid.fdroid

java.lang.IllegalArgumentException: Unexpected char 0xfffd at 30 in x-title value: Wir vertikutieren den Rasen, s�en und d�ngen
	at okhttp3.Headers$Companion.checkValue(SourceFile:87)
	at okhttp3.Headers$Builder.add(SourceFile:14)
	at com.google.net.cronet.okhttptransport.ResponseConverter.toResponse(SourceFile:379)
	at com.google.net.cronet.okhttptransport.CronetInterceptor.intercept(SourceFile:52)
	at okhttp3.internal.http.RealInterceptorChain.proceed(SourceFile:126)
	at okhttp3.internal.connection.RealCall.getResponseWithInterceptorChain$okhttp(SourceFile:97)
	at okhttp3.internal.connection.RealCall$AsyncCall.run(SourceFile:50)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:644)
	at java.lang.Thread.run(Thread.java:1012)

This is the video link:
https://piped.adminforge.de/watch?v=5CSCxN36eKA

This Video shows up in the German trends which is also in the start page of the App.
It seems that it has now a diffrent title. But it looks like the old title was "Wir vertikulieren den Rasen, säen und düngen".

The old video title still shows up in the App in "Trends" but not in the Web Browser instance.
Also the preview picture does not load in LibreTube for the old Video.Screenshot_20240505-171515~2.png

@DanielProg39
Copy link
Author

OK, so I use adminforge.de and kavin.rocks (with CDN) and on both I get this crash (tested by typing "chessboard puzzle" in the search bar).

When I enable the data saver mode, I get no errors or crashes, but when I searched for the term "chessboard puzzle", I understood why the app crashed when I tried to search it without this mode enabled: the first video in the search results seems to be the same video where I initially got the error. You can see this below.

IMG_20240505_191553

This is the video link:
https://piped.adminforge.de/watch?v=5CSCxN36eKA

When I opened it, it played without any problems, but I think it's because it has a different title now (the same situation as my video).

Here some channels that will crash Libretube : Micode, Squeezie, Underscore_, Cyprien

Searching for these channels actually crashes LibreTube. Again, the problem seems to be with the video titles that are loaded first in the search results.

For example, this is the error message I got after searching for Micode:

java.lang.IllegalArgumentException: Unexpected char 0xfffd at 17 in x-title value: La nouvelle mise � jour de l'IA de Meta : Llama 3
 at okhttp3.Headers$Companion.checkValue(Headers.kt:450)
 at okhttp3.Headers$Companion.access$checkValue(Headers.kt:362)
 at okhttp3.Headers$Builder.add(Headers.kt:261)
 at okhttp3.Response$Builder.addHeader(Response.kt:376)
 at com.google.net.cronet.okhttptransport.ResponseConverter.toResponse(ResponseConverter.java:128)
 at com.google.net.cronet.okhttptransport.RequestResponseConverter$1.getResponse(RequestResponseConverter.java:124)
 at com.google.net.cronet.okhttptransport.RequestResponseConverter$CronetRequestAndOkHttpResponse.getResponse(RequestResponseConverter.java:156)
 at com.google.net.cronet.okhttptransport.CronetInterceptor.intercept(CronetInterceptor.java:109)
 at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
 at okhttp3.internal.connection.RealCall.getResponseWithInterceptorChain$okhttp(RealCall.kt:201)
 at okhttp3.internal.connection.RealCall$AsyncCall.run(RealCall.kt:517)
 at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1137)
 at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:637)
 at java.lang.Thread.run(Thread.java:1012)

test with the browser debug tools if there's an x-title header returned in any of the responses if navigating on the instance in the web browser

No. I checked every single connection on both instances and am pretty sure that none of them contained this header.

I also played around with PCAPdroid, but it was useless because of the TLS encryption. However, if you'd like, I can try to decrypt it using a custom root certificate and have a look.

@Bnyro
Copy link
Member

Bnyro commented May 5, 2024

The most helpful thing would be if someone who reproduce the issue

  • runs Android Studio on his PC
  • builds the latest debug build with Android studio
  • reproduces the bug so that the app crashes
  • sends me the whole logcat output from Android Studio

No matter what I try and which instance I use, I still can't reproduce it.

Could somebody share their preference file? Maybe it's related to a certain preference? (I don't know what's happening at all :/)

@Bnyro
Copy link
Member

Bnyro commented May 5, 2024

Might be caused by #5936, which was the only recent change to the image loading logic

@Ganipotes
Copy link

Ganipotes commented May 5, 2024

I found the cause of the crash : DeArrow in Sponsorblock. No crashes after deactivation.

To try to reproduce the crashes you have to enable DeArrow.

That would explain why after enabling the data saver mode there is no crash, that disable images from the DeArrow.

@DanielProg39
Copy link
Author

Is this enough info for troubleshooting? Should I do this:

The most helpful thing would be if someone who reproduce the issue

  • runs Android Studio on his PC
  • builds the latest debug build with Android studio
  • reproduces the bug so that the app crashes
  • sends me the whole logcat output from Android Studio

@DanielProg39
Copy link
Author

I realised that now Bnyro can reproduce the issue and can do this on his own, but I don't mind anyway.

The only strange thing that remains is that when I examined the network in my browser, DeArrow was enabled, yet I didn't find any response containing x-title.

@toas-koas
Copy link

I have the same issue

java.lang.IllegalArgumentException: Unexpected char 0xfffd at 30 in x-title value: Wir vertikutieren den Rasen, s�en und d�ngen at okhttp3.Headers$Companion.checkValue(SourceFile:87) at okhttp3.Headers$Builder.add(SourceFile:14) at com.google.net.cronet.okhttptransport.ResponseConverter.toResponse(SourceFile:379) at com.google.net.cronet.okhttptransport.CronetInterceptor.intercept(SourceFile:52) at okhttp3.internal.http.RealInterceptorChain.proceed(SourceFile:126) at okhttp3.internal.connection.RealCall.getResponseWithInterceptorChain$okhttp(SourceFile:97) at okhttp3.internal.connection.RealCall$AsyncCall.run(SourceFile:50) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1137) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:637) at java.lang.Thread.run(Thread.java:1012)

@Bnyro
Copy link
Member

Bnyro commented May 6, 2024

Fixed with TeamPiped/piped-proxy#178 if Piped Proxy is enabled (we're now removing the header at the proxy's side).

This however won't work when the Piped Proxy is disabled, but I'm afraid we can't skip extracting the header at client side.

Therefore we catch such exceptions now, but you won't be able to load these images from DeArrow with the proxy disabled.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working can't reproduce
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants