TeamNewPipe / NewPipe

A libre lightweight streaming front-end for Android.
https://newpipe.net
GNU General Public License v3.0
31.77k stars 3.09k forks source link

[Bandcamp] NetworkOnMainThreadException when rotating screen on artist/channel page #11183

Open JavkhlanK opened 5 months ago

JavkhlanK commented 5 months ago

Checklist

Affected version

0.27.0

Steps to reproduce the bug

  1. Open an artist on Bandcamp (https://vektroid.bandcamp.com for me)
  2. Open any album
  3. Press the system back button, not the toolbar's since that somehow works

Expected behavior

No response

Actual behavior

The app crashes

Screenshots/Screen recordings

No response

Logs

Exception

android.os.NetworkOnMainThreadException
    at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1675)
    at java.net.Inet6AddressImpl.lookupHostByName(Inet6AddressImpl.java:115)
    at java.net.Inet6AddressImpl.lookupAllHostAddr(Inet6AddressImpl.java:103)
    at java.net.InetAddress.getAllByName(InetAddress.java:1152)
    at okhttp3.Dns$Companion$DnsSystem.lookup(Dns.kt:49)
    at okhttp3.internal.connection.RouteSelector.resetNextInetSocketAddress(RouteSelector.kt:169)
    at okhttp3.internal.connection.RouteSelector.nextProxy(RouteSelector.kt:131)
    at okhttp3.internal.connection.RouteSelector.next(RouteSelector.kt:73)
    at okhttp3.internal.connection.ExchangeFinder.findConnection(ExchangeFinder.kt:205)
    at okhttp3.internal.connection.ExchangeFinder.findHealthyConnection(ExchangeFinder.kt:106)
    at okhttp3.internal.connection.ExchangeFinder.find(ExchangeFinder.kt:74)
    at okhttp3.internal.connection.RealCall.initExchange$okhttp(RealCall.kt:255)
    at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.kt:32)
    at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
    at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.kt:95)
    at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
    at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.kt:83)
    at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
    at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.kt:76)
    at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
    at okhttp3.internal.connection.RealCall.getResponseWithInterceptorChain$okhttp(RealCall.kt:201)
    at okhttp3.internal.connection.RealCall.execute(RealCall.kt:154)
    at org.schabi.newpipe.DownloaderImpl.execute(DownloaderImpl.java:163)
    at org.schabi.newpipe.extractor.downloader.Downloader.post(Downloader.java:143)
    at org.schabi.newpipe.extractor.downloader.Downloader.postWithContentType(Downloader.java:175)
    at org.schabi.newpipe.extractor.downloader.Downloader.postWithContentTypeJson(Downloader.java:217)
    at org.schabi.newpipe.extractor.downloader.Downloader.postWithContentTypeJson(Downloader.java:235)
    at org.schabi.newpipe.extractor.services.bandcamp.extractors.BandcampExtractorHelper.getArtistDetails(BandcampExtractorHelper.java:120)
    at org.schabi.newpipe.extractor.services.bandcamp.linkHandler.BandcampChannelLinkHandlerFactory.getUrl(BandcampChannelLinkHandlerFactory.java:55)
    at org.schabi.newpipe.extractor.linkhandler.ListLinkHandlerFactory.getUrl(ListLinkHandlerFactory.java:77)
    at org.schabi.newpipe.extractor.services.bandcamp.linkHandler.BandcampChannelTabLinkHandlerFactory.getUrl(BandcampChannelTabLinkHandlerFactory.java:56)
    at org.schabi.newpipe.extractor.linkhandler.ListLinkHandlerFactory.fromQuery(ListLinkHandlerFactory.java:57)
    at org.schabi.newpipe.fragments.list.channel.ChannelTabFragment.handleResult(ChannelTabFragment.java:136)
    at org.schabi.newpipe.fragments.list.channel.ChannelTabFragment.handleResult(ChannelTabFragment.java:38)
    at org.schabi.newpipe.fragments.list.BaseListInfoFragment.doInitialLoadLogic(BaseListInfoFragment.java:119)
    at org.schabi.newpipe.fragments.BaseStateFragment.onViewCreated(BaseStateFragment.java:47)
    at androidx.fragment.app.Fragment.performViewCreated(Fragment.java:3147)
    at androidx.fragment.app.FragmentStateManager.createView(FragmentStateManager.java:588)
    at androidx.fragment.app.FragmentStateManager.moveToExpectedState(FragmentStateManager.java:272)
    at androidx.fragment.app.FragmentStore.moveToExpectedState(FragmentStore.java:114)
    at androidx.fragment.app.FragmentManager.moveToState(FragmentManager.java:1455)
    at androidx.fragment.app.FragmentManager.dispatchStateChange(FragmentManager.java:3034)
    at androidx.fragment.app.FragmentManager.dispatchViewCreated(FragmentManager.java:2945)
    at androidx.fragment.app.Fragment.performViewCreated(Fragment.java:3148)
    at androidx.fragment.app.FragmentStateManager.createView(FragmentStateManager.java:588)
    at androidx.fragment.app.FragmentStateManager.moveToExpectedState(FragmentStateManager.java:272)
    at androidx.fragment.app.FragmentManager.executeOpsTogether(FragmentManager.java:1934)
    at androidx.fragment.app.FragmentManager.removeRedundantOperationsAndExecute(FragmentManager.java:1839)
    at androidx.fragment.app.FragmentManager.popBackStackImmediate(FragmentManager.java:891)
    at androidx.fragment.app.FragmentManager.popBackStackImmediate(FragmentManager.java:797)
    at androidx.fragment.app.FragmentManager.handleOnBackPressed(FragmentManager.java:717)
    at androidx.fragment.app.FragmentManager$1.handleOnBackPressed(FragmentManager.java:447)
    at androidx.activity.OnBackPressedDispatcher.onBackPressed(OnBackPressedDispatcher.kt:276)
    at androidx.activity.ComponentActivity.onBackPressed(ComponentActivity.java:678)
    at org.schabi.newpipe.MainActivity.onBackPressed(MainActivity.java:595)
    at android.app.Activity.onKeyUp(Activity.java:4157)
    at android.view.KeyEvent.dispatch(KeyEvent.java:3522)
    at android.app.Activity.dispatchKeyEvent(Activity.java:4505)
    at androidx.core.app.ComponentActivity.superDispatchKeyEvent(ComponentActivity.java:120)
    at androidx.core.view.KeyEventDispatcher.dispatchKeyEvent(KeyEventDispatcher.java:85)
    at androidx.core.app.ComponentActivity.dispatchKeyEvent(ComponentActivity.java:138)
    at androidx.appcompat.app.AppCompatActivity.dispatchKeyEvent(AppCompatActivity.java:604)
    at androidx.appcompat.view.WindowCallbackWrapper.dispatchKeyEvent(WindowCallbackWrapper.java:60)
    at androidx.appcompat.app.AppCompatDelegateImpl$AppCompatWindowCallback.dispatchKeyEvent(AppCompatDelegateImpl.java:3413)
    at com.android.internal.policy.DecorView.dispatchKeyEvent(DecorView.java:678)
    at android.view.ViewRootImpl$ViewPostImeInputStage.processKeyEvent(ViewRootImpl.java:8489)
    at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:8349)
    at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:7682)
    at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:7739)
    at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:7705)
    at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:7908)
    at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:7713)
    at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:7965)
    at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:7686)
    at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:7739)
    at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:7705)
    at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:7713)
    at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:7686)
    at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:7739)
    at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:7705)
    at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:7941)
    at android.view.ViewRootImpl$ImeInputStage.onFinishedInputEvent(ViewRootImpl.java:8183)
    at android.view.inputmethod.InputMethodManager$PendingEvent.run(InputMethodManager.java:4578)
    at android.view.inputmethod.InputMethodManager.invokeFinishedInputEventCallback(InputMethodManager.java:4012)
    at android.view.inputmethod.InputMethodManager.finishedInputEvent(InputMethodManager.java:4003)
    at android.view.inputmethod.InputMethodManager.-$$Nest$mfinishedInputEvent(Unknown Source:0)
    at android.view.inputmethod.InputMethodManager$ImeInputEventSender.onInputEventFinished(InputMethodManager.java:4555)
    at android.view.InputEventSender.dispatchInputEventFinished(InputEventSender.java:154)
    at android.os.MessageQueue.nativePollOnce(Native Method)
    at android.os.MessageQueue.next(MessageQueue.java:335)
    at android.os.Looper.loopOnce(Looper.java:187)
    at android.os.Looper.loop(Looper.java:319)
    at android.app.ActivityThread.main(ActivityThread.java:8919)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:578)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1103)


Affected Android/Custom ROM version

Android 14 / One UI 6.1

Affected device model

Galaxy S22 Ultra

Additional information

It's the same as #10688, but since the author deleted their account…

TobiGr commented 3 weeks ago

I am getting this Exception with the following steps in the current nightly (0.27.2/1003):

  1. Switch to Bandcamp
  2. open a channel / artist apge
  3. rotate

Exception

android.os.NetworkOnMainThreadException
    at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1667)
    at com.android.org.conscrypt.Platform.blockGuardOnNetwork(Platform.java:431)
    at com.android.org.conscrypt.ConscryptEngineSocket$SSLOutputStream.writeInternal(ConscryptEngineSocket.java:666)
    at com.android.org.conscrypt.ConscryptEngineSocket$SSLOutputStream.write(ConscryptEngineSocket.java:661)
    at okio.OutputStreamSink.write(JvmOkio.kt:56)
    at okio.AsyncTimeout$sink$1.write(AsyncTimeout.kt:102)
    at okio.RealBufferedSink.flush(RealBufferedSink.kt:186)
    at okhttp3.internal.http2.Http2Writer.flush(Http2Writer.kt:120)
    at okhttp3.internal.http2.Http2Connection.flush(Http2Connection.kt:408)
    at okhttp3.internal.http2.Http2Stream$FramingSink.close(Http2Stream.kt:624)
    at okio.ForwardingSink.close(ForwardingSink.kt:37)
    at okhttp3.internal.connection.Exchange$RequestBodySink.close(Exchange.kt:247)
    at okio.RealBufferedSink.close(RealBufferedSink.kt:206)
    at okhttp3.internal.http.CallServerInterceptor.intercept(CallServerInterceptor.kt:63)
    at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
    at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.kt:34)
    at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
    at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.kt:95)
    at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
    at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.kt:83)
    at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
    at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.kt:76)
    at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
    at okhttp3.internal.connection.RealCall.getResponseWithInterceptorChain$okhttp(RealCall.kt:201)
    at okhttp3.internal.connection.RealCall.execute(RealCall.kt:154)
    at org.schabi.newpipe.DownloaderImpl.execute(DownloaderImpl.java:163)
    at org.schabi.newpipe.extractor.downloader.Downloader.post(Downloader.java:143)
    at org.schabi.newpipe.extractor.downloader.Downloader.postWithContentType(Downloader.java:175)
    at org.schabi.newpipe.extractor.downloader.Downloader.postWithContentTypeJson(Downloader.java:217)
    at org.schabi.newpipe.extractor.downloader.Downloader.postWithContentTypeJson(Downloader.java:235)
    at org.schabi.newpipe.extractor.services.bandcamp.extractors.BandcampExtractorHelper.getArtistDetails(BandcampExtractorHelper.java:120)
    at org.schabi.newpipe.extractor.services.bandcamp.linkHandler.BandcampChannelLinkHandlerFactory.getUrl(BandcampChannelLinkHandlerFactory.java:56)
    at org.schabi.newpipe.extractor.linkhandler.ListLinkHandlerFactory.getUrl(ListLinkHandlerFactory.java:77)
    at org.schabi.newpipe.extractor.services.bandcamp.linkHandler.BandcampChannelTabLinkHandlerFactory.getUrl(BandcampChannelTabLinkHandlerFactory.java:56)
    at org.schabi.newpipe.extractor.linkhandler.ListLinkHandlerFactory.fromQuery(ListLinkHandlerFactory.java:57)
    at org.schabi.newpipe.fragments.list.channel.ChannelTabFragment.handleResult(ChannelTabFragment.java:137)
    at org.schabi.newpipe.fragments.list.channel.ChannelTabFragment.handleResult(ChannelTabFragment.java:39)
    at org.schabi.newpipe.fragments.list.BaseListInfoFragment.doInitialLoadLogic(BaseListInfoFragment.java:120)
    at org.schabi.newpipe.fragments.BaseStateFragment.onViewCreated(BaseStateFragment.java:47)
    at androidx.fragment.app.Fragment.performViewCreated(Fragment.java:3147)
    at androidx.fragment.app.FragmentStateManager.createView(FragmentStateManager.java:588)
    at androidx.fragment.app.FragmentStateManager.moveToExpectedState(FragmentStateManager.java:272)
    at androidx.fragment.app.FragmentStore.moveToExpectedState(FragmentStore.java:114)
    at androidx.fragment.app.FragmentManager.moveToState(FragmentManager.java:1455)
    at androidx.fragment.app.FragmentManager.dispatchStateChange(FragmentManager.java:3034)
    at androidx.fragment.app.FragmentManager.dispatchViewCreated(FragmentManager.java:2945)
    at androidx.fragment.app.Fragment.performViewCreated(Fragment.java:3148)
    at androidx.fragment.app.FragmentStateManager.createView(FragmentStateManager.java:588)
    at androidx.fragment.app.FragmentStateManager.moveToExpectedState(FragmentStateManager.java:272)
    at androidx.fragment.app.FragmentStore.moveToExpectedState(FragmentStore.java:114)
    at androidx.fragment.app.FragmentManager.moveToState(FragmentManager.java:1455)
    at androidx.fragment.app.FragmentManager.dispatchStateChange(FragmentManager.java:3034)
    at androidx.fragment.app.FragmentManager.dispatchActivityCreated(FragmentManager.java:2952)
    at androidx.fragment.app.FragmentController.dispatchActivityCreated(FragmentController.java:263)
    at androidx.fragment.app.FragmentActivity.onStart(FragmentActivity.java:350)
    at androidx.appcompat.app.AppCompatActivity.onStart(AppCompatActivity.java:251)
    at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1547)
    at android.app.Activity.performStart(Activity.java:8367)
    at android.app.ActivityThread.handleStartActivity(ActivityThread.java:3670)
    at android.app.servertransaction.TransactionExecutor.performLifecycleSequence(TransactionExecutor.java:224)
    at android.app.servertransaction.TransactionExecutor.cycleToPath(TransactionExecutor.java:204)
    at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:176)
    at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:97)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2307)
    at android.os.Handler.dispatchMessage(Handler.java:106)
    at android.os.Looper.loopOnce(Looper.java:201)
    at android.os.Looper.loop(Looper.java:288)
    at android.app.ActivityThread.main(ActivityThread.java:7924)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)


TobiGr commented 3 weeks ago

The problem is that the current Bandcamp implementation is doing network requests when calling BandcampChannelLinkHandlerFactory.getUrl() and BandcampChannelLinkHandlerFactory.getId(). The other services do not need to perform a request for their implementations.