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 detection of network related exceptions #3294

Merged
merged 2 commits into from
Apr 10, 2020

Conversation

mauriciocolli
Copy link
Contributor

What is it?

  • Bug fix
  • Feature

Long description of the changes in your PR

I saw a few of these in some reports lately, because when a network exception occurs, some other method will sometimes wrap that exception and cause it not to be detected by the simple instanceof checks.

This adds a class that checks whether some exception in the chain is of some network issue related type.

Fixes the following issue(s)

Testing apk

fix-network-issues-detection.apk.zip

@mauriciocolli mauriciocolli added ASAP Issue needs to be fixed as soon as possible bug Issue is related to a bug labels Mar 28, 2020
@mauriciocolli mauriciocolli mentioned this pull request Mar 28, 2020
@wb9688
Copy link
Contributor

wb9688 commented Mar 29, 2020

This is one solution. However, with yt_new we also had this bug, and we decided that it's better to still just throw the IOException in NewPipeExtractor. We could reevaluate that choice though.

@mauriciocolli
Copy link
Contributor Author

@wb9688: However, with yt_new we also had this bug, and we decided that it's better to still just throw the IOException in NewPipeExtractor.

Yes, throwing a IOException is not a problem, the problem is that some exceptions wrap it, and that can hide network errors here.

The only time that a IOException would be throw, would be in a situation where the network can't make/complete the request. If it can make it at all, a response will always be returned, is up to the extractor code detect error situations (e.g. received a 4xx).

Example (and a major source of reports) in the extractor where this error is hidden (where arguably it shouldn't). Any I/O error, like a slow network timing out that request, would result in a DecryptException.

Fortunately, this is already handled correctly (i.e. not catching it) and only a few places there have this problem. This pull request would just make this check more thorough on this side, which help in some cases.

@TobiGr TobiGr added this to the 0.19.3 milestone Apr 6, 2020
wb9688
wb9688 previously approved these changes Apr 8, 2020
Copy link
Contributor

@wb9688 wb9688 left a comment

Choose a reason for hiding this comment

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

Ah, you're correct. I looked at the code and it looks good. You have to rebase though.

@TobiGr
Copy link
Member

TobiGr commented Apr 9, 2020

Just tested this a bit further and got one error which I did not expect.
To reproduce it, turn of all internet connections or enable airplane mode, open NewPipe and see the YouTube trending kiosk. => Normal network error & retry button. With SoundCloud I can get this error.

Log

org.schabi.newpipe.report.ErrorActivity: java.net.UnknownHostException: Unable to resolve host "soundcloud.com": No address associated with hostname
        at java.net.InetAddress.lookupHostByName(InetAddress.java:424)
        at java.net.InetAddress.getAllByNameImpl(InetAddress.java:236)
        at java.net.InetAddress.getAllByName(InetAddress.java:214)
        at okhttp3.Dns$1.lookup(Dns.java:40)
        at okhttp3.internal.connection.RouteSelector.resetNextInetSocketAddress(RouteSelector.java:185)
        at okhttp3.internal.connection.RouteSelector.nextProxy(RouteSelector.java:149)
        at okhttp3.internal.connection.RouteSelector.next(RouteSelector.java:84)
        at okhttp3.internal.connection.StreamAllocation.findConnection(StreamAllocation.java:215)
        at okhttp3.internal.connection.StreamAllocation.findHealthyConnection(StreamAllocation.java:135)
        at okhttp3.internal.connection.StreamAllocation.newStream(StreamAllocation.java:114)
        at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.java:42)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121)
        at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.java:93)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121)
        at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.java:93)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
        at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.java:127)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121)
        at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:257)
        at okhttp3.RealCall.execute(RealCall.java:93)
        at org.schabi.newpipe.DownloaderImpl.execute(DownloaderImpl.java:214)
        at org.schabi.newpipe.extractor.downloader.Downloader.get(Downloader.java:70)
        at org.schabi.newpipe.extractor.downloader.Downloader.get(Downloader.java:29)
        at org.schabi.newpipe.extractor.services.soundcloud.SoundcloudParsingHelper.clientId(SoundcloudParsingHelper.java:49)
        at org.schabi.newpipe.extractor.services.soundcloud.SoundcloudChartsExtractor.computeNextPageAndStreams(SoundcloudChartsExtractor.java:52)
        at org.schabi.newpipe.extractor.services.soundcloud.SoundcloudChartsExtractor.getInitialPage(SoundcloudChartsExtractor.java:81)
        at org.schabi.newpipe.extractor.utils.ExtractorHelper.getItemsPageOrLogError(ExtractorHelper.java:19)
        at org.schabi.newpipe.extractor.kiosk.KioskInfo.getInfo(KioskInfo.java:72)
        at org.schabi.newpipe.extractor.kiosk.KioskInfo.getInfo(KioskInfo.java:58)
        at org.schabi.newpipe.util.ExtractorHelper.lambda$getKioskInfo$11(ExtractorHelper.java:183)
        at org.schabi.newpipe.util.-$$Lambda$ExtractorHelper$3nu_IUHVaX-6ert-LLLuUGJnfDU.call(lambda)
        at io.reactivex.internal.operators.single.SingleFromCallable.subscribeActual(SingleFromCallable.java:44)
        at io.reactivex.Single.subscribe(Single.java:3438)
        at io.reactivex.internal.operators.single.SingleDoOnSuccess.subscribeActual(SingleDoOnSuccess.java:35)
        at io.reactivex.Single.subscribe(Single.java:3438)
        at io.reactivex.internal.operators.single.SingleSubscribeOn$SubscribeOnObserver.run(SingleSubscribeOn.java:89)
        at io.reactivex.Scheduler$DisposeTask.run(Scheduler.java:578)
        at io.reactivex.internal.schedulers.ScheduledRunnable.run(ScheduledRunnable.java:66)
        at io.reactivex.internal.schedulers.ScheduledRunnable.call(ScheduledRunnable.java:57)
        at java.util.concurrent.FutureTask.run(FutureTask.java:237)
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:152)
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:265)
    	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.ja

@mauriciocolli
Copy link
Contributor Author

mauriciocolli commented Apr 10, 2020

@TobiGr: There it is, one more gotta catch 'em all situation. The method below also suffers from it.

Now, the reason why only SoundCloud have this problem: the others implement the onFetchPage while SoundCloud's charts extractor doesn't, causing the others to fail before that method is called.

It actually returns a info object with the network error in its error list, that's why it's only a snackbar message.

@TobiGr
Copy link
Member

TobiGr commented Apr 10, 2020

@mauriciocolli Thanks for taking a look at this.

@TobiGr TobiGr merged commit 9cb6816 into TeamNewPipe:dev Apr 10, 2020
This was referenced Apr 24, 2020
@mauriciocolli mauriciocolli deleted the fix-network-issues-detection branch December 8, 2021 16:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ASAP Issue needs to be fixed as soon as possible bug Issue is related to a bug
Projects
None yet
3 participants