Nativescript: Problem with ui/frame on getFragmentCallbacks

Created on 28 Sep 2017  路  15Comments  路  Source: NativeScript/NativeScript

Please, provide the details below:

Application crashes when navigating back on several views really fast and with the activityBackPressedEvent cancelling the back button on first view.

Did you verify this is a real problem by searching [Stack Overflow]

Yes, I've searched and couldn't find anything.

Tell us about the problem

I've created an app with some views and I need to block the back button ONLY on the first view with the activityBackPressedEvent.
Basically I've done this on the navigatedTo function of the first view:

mainPage = args.object;
if(app.android) {
      app.android.on(app.AndroidApplication.activityBackPressedEvent, backEvent);
}

And on the backEvent function I've put:

function backEvent(args) {
    var currentPage = frameModule.topmost().currentPage;
    if(mainPage == currentPage)
        args.cancel = true;
}

Basically it works as expected except when I'm on view 5 and click several times on the back button, that's when the app crashes:
22091571_1647154951996162_1123662885_n

Which platform(s) does your issue occur on?

Android

Please provide the following version numbers that your issue occurs with:

  • CLI: 3.2.1
  • Cross-platform modules: ~3.2.0
  • Runtime(s): 3.2.0

Please tell us how to recreate the issue in as much detail as possible.

Create some views and the navigation between them like View 1 --> View 2 --> View 3 --> View 4 --> View 5 and click on the back button really fast a lot of times. Also, insert the code I've put on the description of my problem in the code of first view.

Is there code involved? If so, please share the minimal amount of code needed to recreate the problem.

Already on the description of the problem.

android high

Most helpful comment

@pedromareis This should be fixed in master branch and will be included in 3.4
If possible please try it with @next of tns-core-modules and ping me back if issue is still present.

All 15 comments

I've also tried to reproduce this issue with NativeScript 2.5.0 and there's no problem at all, it does the action expected.

Hi @pedromareis ,
I tested the described scenario while using NativeScript 3.2.1 and the description from this blog post, however, I was unable to recreate the similar problem. Keep in mind that I registered activityBackPressedEvent inside the app.ts file as it is described on the blog and where it is the right place to do that.

For your convenience, I am attaching GIF file from the simulator and sample project. You can review it and make the needed changes, which will allow us to recreate behavior.
Archive.zip
screencast 2017-09-28 at 4 31 50 pm

Hello @tsonevn,
From what I've seen from the gif I guess you're doing the activityBackPressedEvent only on the last view (View 6) instead of doing it on view 1... And even if you remove the event I think you can see the error too when navigating from view 6 to 1 pressing multiple times the back button...

Hi @pedromareis,
In sample project, I disabled the back button in the app.ts file for the whole application inside the callback method for the activityBackPressedEvent.

The scenarios that I tested on our devices are as follows:

  1. I navigated to the latest page and tap several times on the hardware back button. In this case, the callback method was executed properly and the navigation was canceled properly.
  2. on the second scenario I navigated to the very first page, again without to be able to crash the application.

The described scenarios could be reviewed in the attached video and by building the attached project on your side.

To be able to investigate further the problem, it would help if you could send us sample project.
Archive.zip

video.zip

Hey @tsonevn, I'm attaching a video of the issue occurring and the sample project where it happened. Also, be aware that I haven't disabled the back button and it still occurs when navigating back from view 4 to view 1.

Video.zip
test1.zip

@tsonevn any updates on this?

Hi @pedromareis,
We reviewed your project, however as you could see on the attached GIF file, still the project is built properly and the navigation works as expected. The project was tested on Android simulator API level 23 similar to yours, Could you verify, whether I am missing some step on the attached gif?
screencast 2017-10-02 at 5 23 10 pm

@tsonevn well, from what I see in the gif I don't think you're doing it exactly like I did... The problem only occurs if you tap quickly on the back button and multiple times. Could you try that?

Basically I don't even give the app time to process all the taps on the back button and the app eventually crashes because of that.

@pedromareis,

Indeed you are right, to reproduce the problem, the Back button should be tapped quickly multiple times.
I tested this case with the official version and with @next of the modules. Unfortunately, the issue is reproduced with both. Regarding that, I would suggest keeping track on the issue for further info about the case.

Any updates on when will this be fixed?

Hi @pedromareis,
We are working on resolving this problem. We will provide more info in the issue when we have a solution.

@pedromareis This should be fixed in master branch and will be included in 3.4
If possible please try it with @next of tns-core-modules and ping me back if issue is still present.

Hello @hshristov, I've just updated the core modules and everything seems to be okay. Thank you!!

@pedromareis That's great.
Thanks for taking time to verify it. Really appreciate it.

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

hshristov picture hshristov  路  3Comments

dhanalakshmitawwa picture dhanalakshmitawwa  路  3Comments

minjunlan picture minjunlan  路  3Comments

valentinstoychev picture valentinstoychev  路  3Comments

kn9ts picture kn9ts  路  3Comments