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

Migrate to AndroidX #2685

Merged
merged 2 commits into from
Oct 6, 2019
Merged

Migrate to AndroidX #2685

merged 2 commits into from
Oct 6, 2019

Conversation

Redirion
Copy link
Member

@Redirion Redirion commented Oct 4, 2019

Third attempt.
This PR supersedes PR #2598 (seems to be no longer maintained).
This was finally possible after PR #2535 was merged.
I took the stable approach for continued usage of the modified FlingBehavior.java from this commit 0d25645

Closes #2641

Debug apk: https://github.com/Redirion/NewPipe/releases/download/v0.17.4/app-debug.apk

Note that I left everything unchanged, the Extractor still has the NullPointerException on getChannelCount.

@snappyapple632
Copy link

snappyapple632 commented Oct 6, 2019

Tested the APK for a couple of days now, no issues on my end.

@EmmanuelMess
Copy link

This PR supersedes PR #2598 (seems to be no longer maintained).

Very sorry about that.

Copy link
Contributor

@mauriciocolli mauriciocolli left a comment

Choose a reason for hiding this comment

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

Good to merge!

@mauriciocolli
Copy link
Contributor

Oh, just noticed that I don't have the permissions to approve pull requests anymore (was inactive for some time), it is good to merge though.

Copy link
Member

@TobiGr TobiGr left a comment

Choose a reason for hiding this comment

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

Thanks for taking on this again!
The migration even brings some layout fixes for KitKat ❤️
image

@TobiGr TobiGr merged commit ce17cca into TeamNewPipe:dev Oct 6, 2019
@Redirion Redirion deleted the androidx3 branch October 7, 2019 03:20
@TobiGr
Copy link
Member

TobiGr commented Oct 7, 2019

@Redirion Below is the exception from #2697. I was able to reproduce it. It happens when rotating the screen on a channel page twice. E.g from portrait to landscape and back again. I guess this is what I did when opening the video and rotating the phone to view a video in landscape. However, I tried this with commits before this PR and did produce the crash. Would be good if you can take a look at it.

Exception

  • User Action: ui error
  • Request: App crash, UI failure
  • Content Language: GB
  • Service: none
  • Version: 0.17.3
  • OS: Linux ,release-keys 6.0 - 23
Crash log

java.lang.RuntimeException: Unable to destroy activity {org.schabi.newpipe.debug/org.schabi.newpipe.MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'void androidx.viewpager.widget.ViewPager.setAdapter(androidx.viewpager.widget.PagerAdapter)' on a null object reference
	at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:3852)
	at android.app.ActivityThread.handleDestroyActivity(ActivityThread.java:3870)
	at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:4074)
	at android.app.ActivityThread.-wrap15(ActivityThread.java)
	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1360)
	at android.os.Handler.dispatchMessage(Handler.java:102)
	at android.os.Looper.loop(Looper.java:148)
	at android.app.ActivityThread.main(ActivityThread.java:5443)
	at java.lang.reflect.Method.invoke(Native Method)
	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:728)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void androidx.viewpager.widget.ViewPager.setAdapter(androidx.viewpager.widget.PagerAdapter)' on a null object reference
	at org.schabi.newpipe.fragments.MainFragment.onDestroy(MainFragment.java:115)
	at androidx.fragment.app.Fragment.performDestroy(Fragment.java:2830)
	at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManagerImpl.java:1028)
	at androidx.fragment.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManagerImpl.java:1238)
	at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManagerImpl.java:1310)
	at androidx.fragment.app.FragmentManagerImpl.dispatchStateChange(FragmentManagerImpl.java:2659)
	at androidx.fragment.app.FragmentManagerImpl.dispatchDestroy(FragmentManagerImpl.java:2644)
	at androidx.fragment.app.FragmentController.dispatchDestroy(FragmentController.java:329)
	at androidx.fragment.app.FragmentActivity.onDestroy(FragmentActivity.java:366)
	at androidx.appcompat.app.AppCompatActivity.onDestroy(AppCompatActivity.java:233)
	at org.schabi.newpipe.MainActivity.onDestroy(MainActivity.java:352)
	at android.app.Activity.performDestroy(Activity.java:6415)
	at android.app.Instrumentation.callActivityOnDestroy(Instrumentation.java:1165)
	at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:3839)
	... 10 more
java.lang.NullPointerException: Attempt to invoke virtual method 'void androidx.viewpager.widget.ViewPager.setAdapter(androidx.viewpager.widget.PagerAdapter)' on a null object reference
	at org.schabi.newpipe.fragments.MainFragment.onDestroy(MainFragment.java:115)
	at androidx.fragment.app.Fragment.performDestroy(Fragment.java:2830)
	at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManagerImpl.java:1028)
	at androidx.fragment.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManagerImpl.java:1238)
	at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManagerImpl.java:1310)
	at androidx.fragment.app.FragmentManagerImpl.dispatchStateChange(FragmentManagerImpl.java:2659)
	at androidx.fragment.app.FragmentManagerImpl.dispatchDestroy(FragmentManagerImpl.java:2644)
	at androidx.fragment.app.FragmentController.dispatchDestroy(FragmentController.java:329)
	at androidx.fragment.app.FragmentActivity.onDestroy(FragmentActivity.java:366)
	at androidx.appcompat.app.AppCompatActivity.onDestroy(AppCompatActivity.java:233)
	at org.schabi.newpipe.MainActivity.onDestroy(MainActivity.java:352)
	at android.app.Activity.performDestroy(Activity.java:6415)
	at android.app.Instrumentation.callActivityOnDestroy(Instrumentation.java:1165)
	at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:3839)
	at android.app.ActivityThread.handleDestroyActivity(ActivityThread.java:3870)
	at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:4074)
	at android.app.ActivityThread.-wrap15(ActivityThread.java)
	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1360)
	at android.os.Handler.dispatchMessage(Handler.java:102)
	at android.os.Looper.loop(Looper.java:148)
	at android.app.ActivityThread.main(ActivityThread.java:5443)
	at java.lang.reflect.Method.invoke(Native Method)
	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:728)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)


@Redirion
Copy link
Member Author

Redirion commented Oct 7, 2019

It might be easily mitigated with a null check but fixing the root cause which looks like a race condition between destroying and recreating the views. I will have a look tomorrow morning

@Redirion
Copy link
Member Author

Redirion commented Oct 8, 2019

I went ahead with the simple fix. There was no obvious root cause and nulling the adapter of the ViewPager to clean it up is the correct thing to do. So I just added the null check inline with the other Fragment classes.

This was referenced Oct 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

update to Android X
5 participants