Skip to content

Error when using animated transition during navigation on Android 21 and 22 #5674

@darind

Description

@darind

Tell us about the problem

An error is thrown if using slide animation during navigation

Which platform(s) does your issue occur on?

Android

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

  • CLI: 4.0.0
  • Cross-platform modules: 4.0.0
  • Runtime(s): 4.0.0
  • Plugin(s): N/A

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

Create a new {N} application using CLI 4.0.0:

tns create my-app --tsc

On the main page add a button with a tap event calling into a function that will navigate to a second page:

public navigateToSecondPage(): void {
    topmost().navigate({
        moduleName: "component/component-page",
        animated: true,
        transition: {
            name: "slide",
            duration: 200,
            curve: "ease"
        }
    });
}

In the second page view model constructor try to open some url (opening the url doesn't necessarily need to be done inside the constructor - the problem occurs also if this is done inside a click of a button):

import { Observable } from "tns-core-modules/data/observable";
import { openUrl } from "utils/utils";

export class ComponentViewModel extends Observable {
    constructor() {
        super();
        openUrl("https://www.google.com");
    }
}

On Android API levels 21 and 22, the following exception is thrown:

W/System.err(16021): java.lang.NullPointerException: Attempt to read from field 'int android.app.Fragment.mContainerId' on a null object reference
W/System.err(16021):    at android.app.BackStackRecord$1.onPreDraw(BackStackRecord.java:1127)
W/System.err(16021):    at android.view.ViewTreeObserver.dispatchOnPreDraw(ViewTreeObserver.java:847)
W/System.err(16021):    at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1956)
W/System.err(16021):    at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1054)
W/System.err(16021):    at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5779)
W/System.err(16021):    at android.view.Choreographer$CallbackRecord.run(Choreographer.java:767)
W/System.err(16021):    at android.view.Choreographer.doCallbacks(Choreographer.java:580)
W/System.err(16021):    at android.view.Choreographer.doFrame(Choreographer.java:550)
W/System.err(16021):    at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:753)
W/System.err(16021):    at android.os.Handler.handleCallback(Handler.java:739)
W/System.err(16021):    at android.os.Handler.dispatchMessage(Handler.java:95)
W/System.err(16021):    at android.os.Looper.loop(Looper.java:135)
W/System.err(16021):    at android.app.ActivityThread.main(ActivityThread.java:5221)
W/System.err(16021):    at java.lang.reflect.Method.invoke(Native Method)
W/System.err(16021):    at java.lang.reflect.Method.invoke(Method.java:372)
W/System.err(16021):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
W/System.err(16021):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)

If I remove the animated: true or the slide transition when navigating the issue will not manifest.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions