apps-android-commons icon indicating copy to clipboard operation
apps-android-commons copied to clipboard

Crash on notification and fails on image upload

Open michygeek opened this issue 8 years ago • 18 comments

Summary:

The app crash when ever I click on the Notification feature and I was unable to upload image, showing "Failed" most time I tried

Steps to reproduce:

Quite easy. Login and click on the "Notification" it crashes Also, the second issues is quite simple as I only tried to upload image.

Add System logs:

Device and Android version:

Tecno droid pad Android 5.0 1gb Ram and 16gb Rom

Screen-shots:

20181029_054242

Would you like to work on the issue? I would have love to solve this issue but I am not a developer.

michygeek avatar Oct 29 '18 08:10 michygeek

I will look into it. I am not able to reproduce it on Android 7.0 though. So I will try it on Android 5.0

konohakesh avatar Oct 29 '18 18:10 konohakesh

OK, Thank you!

michygeek avatar Oct 29 '18 19:10 michygeek

Ok I could reproduce this in Android 5.0 where it fails with following stack trace:

E/AndroidRuntime: FATAL EXCEPTION: main Process: fr.free.nrw.commons.beta, PID: 8726 java.util.regex.PatternSyntaxException: Unrecognized backslash escape sequence in pattern near index 4: (^\h*)|(\h*$) ^ at java.util.regex.Pattern.compileImpl(Native Method) at java.util.regex.Pattern.compile(Pattern.java:411) at java.util.regex.Pattern.(Pattern.java:394) at java.util.regex.Pattern.compile(Pattern.java:381) at java.lang.String.replaceAll(String.java:1600) at fr.free.nrw.commons.notification.NotificationRenderer.setTitle(NotificationRenderer.java:60) at fr.free.nrw.commons.notification.NotificationRenderer.render(NotificationRenderer.java:50) at com.pedrogomez.renderers.RVRendererAdapter.onBindViewHolder(RVRendererAdapter.java:121) at com.pedrogomez.renderers.RVRendererAdapter.onBindViewHolder(RVRendererAdapter.java:41) at android.support.v7.widget.RecyclerView$Adapter.onBindViewHolder(RecyclerView.java:6673) at android.support.v7.widget.RecyclerView$Adapter.bindViewHolder(RecyclerView.java:6714) at android.support.v7.widget.RecyclerView$Recycler.tryBindViewHolderByDeadline(RecyclerView.java:5647) at android.support.v7.widget.RecyclerView$Recycler.tryGetViewHolderForPositionByDeadline(RecyclerView.java:5913) at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:5752) at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:5748) at android.support.v7.widget.LinearLayoutManager$LayoutState.next(LinearLayoutManager.java:2232) at android.support.v7.widget.LinearLayoutManager.layoutChunk(LinearLayoutManager.java:1559) at android.support.v7.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1519) at android.support.v7.widget.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java:614) at android.support.v7.widget.RecyclerView.dispatchLayoutStep2(RecyclerView.java:3812) at android.support.v7.widget.RecyclerView.dispatchLayout(RecyclerView.java:3529) at android.support.v7.widget.RecyclerView.onLayout(RecyclerView.java:4082) at android.view.View.layout(View.java:15671) at android.view.ViewGroup.layout(ViewGroup.java:5038) at android.widget.RelativeLayout.onLayout(RelativeLayout.java:1076) at android.view.View.layout(View.java:15671) at android.view.ViewGroup.layout(ViewGroup.java:5038) at android.support.v4.widget.DrawerLayout.onLayout(DrawerLayout.java:1171) at android.view.View.layout(View.java:15671) at android.view.ViewGroup.layout(ViewGroup.java:5038) at android.widget.FrameLayout.layoutChildren(FrameLayout.java:579) at android.widget.FrameLayout.onLayout(FrameLayout.java:514) at android.view.View.layout(View.java:15671) at android.view.ViewGroup.layout(ViewGroup.java:5038) at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1703) at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1557) at android.widget.LinearLayout.onLayout(LinearLayout.java:1466) at android.view.View.layout(View.java:15671) at android.view.ViewGroup.layout(ViewGroup.java:5038) at android.widget.FrameLayout.layoutChildren(FrameLayout.java:579) at android.widget.FrameLayout.onLayout(FrameLayout.java:514) at android.view.View.layout(View.java:15671) at android.view.ViewGroup.layout(ViewGroup.java:5038) at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1703) at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1557) at android.widget.LinearLayout.onLayout(LinearLayout.java:1466) at android.view.View.layout(View.java:15671) at android.view.ViewGroup.layout(ViewGroup.java:5038) at android.widget.FrameLayout.layoutChildren(FrameLayout.java:579) at android.widget.FrameLayout.onLayout(FrameLayout.java:514) at android.view.View.layout(View.java:15671) at android.view.ViewGroup.layout(ViewGroup.java:5038) at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:2086) at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1843) at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1061) at android.view.ViewRootImpl$TraversalRunnable.run(ViewR

Apparently '\h' pattern is not recognized by Pattern class in Android 5 but gets recognized in higher versions (atleast in Android 7.0).

There are two things here:

  1. I am not getting why replaceAll for whitespaces in front or end is required post trim() in here: notificationText = notificationText.trim().replaceAll("(^\h*)|(\h*$)", "");
  2. If I missed anything here and we need replaceAll then can we go with '\s' escape sequence which is working on both Android versions.

What do you think @misaochan ?

konohakesh avatar Oct 29 '18 20:10 konohakesh

Thanks for the investigations @konohakesh . :)

  1. I believe we found trim() to be insufficient for tidying up whitespaces. AFAIK this was implemented by @maskaravivek - Vivek, do you recall why replaceAll was needed?
  2. I looked up https://developer.android.com/reference/java/util/regex/Pattern and it seems that indeed '\s' is the recommended character sequence for whitespace. Please feel free to go for it. :)

misaochan avatar Oct 30 '18 07:10 misaochan

Also, I tried to upload image with Android 6.0 but the image failed (similar to the issue on 5.0) to upload after several attempt.

michygeek avatar Oct 30 '18 08:10 michygeek

@tykees , what version of the app are you using? Could you check About and let us know please?

misaochan avatar Oct 30 '18 08:10 misaochan

screenshot_2018-10-30-10-42-04 Latest version on F-driod

michygeek avatar Oct 30 '18 09:10 michygeek

Strange that F-droid has not taken up 2.8.6 yet. I have been tagging releases and it is available here. Is there a delay for deployment?

Image upload failures were fixed in 2.8.5, so it is expected that you would experience failures, if you are running 2.8.4.

misaochan avatar Oct 30 '18 16:10 misaochan

With what I can see, that update and release was 24hrs ago. The latest version on play store and F-driod is still 2.8.4, I will update once I can get the apk or any downloadable version of the app.

michygeek avatar Oct 30 '18 17:10 michygeek

2.8.5, which does fix upload failures, was 19 days ago. I am a bit concerned that F-droid has not updated it?

The latest production version on the Play Store should be 2.8.5 too. Are you certain it is 2.8.4 for you? Could you try uninstalling and reinstalling your app? Sometimes the Play Store app caches and does not display the current version.

misaochan avatar Oct 30 '18 17:10 misaochan

I had totally missed this second issue you are getting while image upload, at the time of reading the defect.

But now I went ahead and tried to reproduce it on Android 5, 6 and 7.0 . I could not reproduce it. So may be it is fixed as everyone else is saying. I will go ahead and create a PR for the earlier issue.

konohakesh avatar Oct 30 '18 18:10 konohakesh

Has directed by @misaochan, I uninstall the one I downloaded from F-driod and I downloads from playstore. but, the issue still reoccur when I tried to upload.

michygeek avatar Oct 30 '18 19:10 michygeek

@misaochan Are we ready to roll out 2.8.6 to all users? That way @tykees can share logs from his app. :)

maskaravivek avatar Oct 31 '18 06:10 maskaravivek

@tykees Hmm. Could I please trouble you to do this:

  • Opt in to beta testing at https://play.google.com/apps/testing/fr.free.nrw.commons
  • Update to 2.8.6
  • Go to Settings > Send log file
  • Tap Send log file
  • Restart your app
  • Perform an upload
  • After it fails, tap Send log file again

This will help us debug the cause of the failure for you. :)

@maskaravivek This is a tricky decision, and I eventually decided to leave 2.8.6 in beta. The reason is that from 1 Nov 2018, all app updates must target API 26 or higher, so this means that further hotfixes to 2.8-release are not possible without cherrpicking the API 26 fixes from master - i.e. time-consuming. 2.8.5 has been around for 20+ days now and is relatively stable, so I can reasonably trust that it will hold on til we can stabilize master for a release. I can't say the same of 2.8.6.

My rationale is that most people who would send logs to us anyway are already in beta testing or could be requested to sign up for beta testing.

misaochan avatar Oct 31 '18 09:10 misaochan

Okey, thanks! Doing that now

michygeek avatar Oct 31 '18 10:10 michygeek

Done!

michygeek avatar Oct 31 '18 10:10 michygeek

Thanks @tykees !

@maskaravivek Please see the logs here. It seems to be a badtoken error.

error code="badtoken" info="The centralauthtoken is not valid."

misaochan avatar Oct 31 '18 11:10 misaochan

Uploads have been refactored as a part of backend-overhaul, as the crash on notification click has already been merged. Closing this issue

ashishkumar468 avatar Aug 17 '20 10:08 ashishkumar468