nativescript-community / nativescript-community/universal-links

App crashes when trying to navigate

Open
#3 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
26
Forks
8
PR merge metrics
No merged PRs in 30d

Description

The call back works perfectly. The app opens with the link, but when i try to navigate to some page the i gets an error:

System.err: An uncaught Exception occurred on "main" thread.
System.err: Unable to resume activity {org.nativescript.tripper/com.tns.NativeScriptActivity}: com.tns.NativeScriptException: Calling js method onViewAttachedToWindow failed
System.err: Error: java.lang.IllegalStateException: FragmentManager is already executing transactions
System.err:
System.err: StackTrace:
System.err: java.lang.RuntimeException: Unable to resume activity {org.nativescript.tripper/com.tns.NativeScriptActivity}: com.tns.NativeScriptException: Calling js method onViewAttachedToWindow failed
System.err: Error: java.lang.IllegalStateException: FragmentManager is already executing transactions
System.err: at android.app.ActivityThread.performResumeActivity(ActivityThread.java:4270)
System.err: at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:4302)
System.err: at android.app.servertransaction.ResumeActivityItem.execute(ResumeActivityItem.java:52)
System.err: at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:176)
System.err: at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:97)
System.err: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2044)
System.err: at android.os.Handler.dispatchMessage(Handler.java:107)
System.err: at android.os.Looper.loop(Looper.java:224)
System.err: at android.app.ActivityThread.main(ActivityThread.java:7562)
System.err: at java.lang.reflect.Method.invoke(Native Method)
System.err: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:539)
System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:950)
System.err: Caused by: com.tns.NativeScriptException: Calling js method onViewAttachedToWindow failed
System.err: Error: java.lang.IllegalStateException: FragmentManager is already executing transactions
System.err: at com.tns.Runtime.callJSMethodNative(Native Method)
System.err: at com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1286)
System.err: at com.tns.Runtime.callJSMethodImpl(Runtime.java:1173)
System.err: at com.tns.Runtime.callJSMethod(Runtime.java:1160)
System.err: at com.tns.Runtime.callJSMethod(Runtime.java:1138)
System.err: at com.tns.Runtime.callJSMethod(Runtime.java:1134)
System.err: at com.tns.gen.java.lang.Object_vendor_105194_32_AttachListener.onViewAttachedToWindow(Object_vendor_105194_32_AttachListener.java:18)
System.err: at android.view.View.dispatchAttachedToWindow(View.java:19676)
System.err: at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3458)
System.err: at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3465)
System.err: at android.view.ViewGroup.addViewInner(ViewGroup.java:5181)
System.err: at android.view.ViewGroup.addView(ViewGroup.java:4967)
System.err: at android.view.ViewGroup.addView(ViewGroup.java:4904)
System.err: at android.view.ViewGroup.addView(ViewGroup.java:4877)
System.err: at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManagerImpl.java:880)
System.err: at androidx.fragment.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManagerImpl.java:1228)
System.err: at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManagerImpl.java:1293)
System.err: at androidx.fragment.app.BackStackRecord.executeOps(BackStackRecord.java:439)
System.err: at androidx.fragment.app.FragmentManagerImpl.executeOps(FragmentManagerImpl.java:2066)
System.err: at androidx.fragment.app.FragmentManagerImpl.executeOpsTogether(FragmentManagerImpl.java:1856)
System.err: at androidx.fragment.app.FragmentManagerImpl.removeRedundantOperationsAndExecute(FragmentManagerImpl.java:1811)
System.err: at androidx.fragment.app.FragmentManagerImpl.execPendingActions(FragmentManagerImpl.java:1717)
System.err: at androidx.fragment.app.FragmentController.execPendingActions(FragmentController.java:446)
System.err: at androidx.fragment.app.FragmentActivity.onResume(FragmentActivity.java:459)
System.err: at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1454)
System.err: at android.app.Activity.performResume(Activity.java:8050)
System.err: at android.app.ActivityThread.performResumeActivity(ActivityThread.java:4260)
System.err: ... 11 more
System.err: Caused by: java.lang.IllegalStateException: FragmentManager is already executing transactions
System.err: at androidx.fragment.app.FragmentManagerImpl.ensureExecReady(FragmentManagerImpl.java:1650)
System.err: at androidx.fragment.app.FragmentManagerImpl.execSingleAction(FragmentManagerImpl.java:1682)
System.err: at androidx.fragment.app.BackStackRecord.commitNowAllowingStateLoss(BackStackRecord.java:299)
System.err: ... 38 more

My code looks like this:

import { Component, NgZone, OnInit } from "@angular/core";
import { Router } from "@angular/router";
import { registerUniversalLinkCallback } from "@nativescript-community/universal-links";

@Component({
    selector: "ns-app",
    templateUrl: "./app.component.html"
})
export class AppComponent implements OnInit {
    constructor(private router: Router,
        private zone: NgZone){}

    ngOnInit() {
        registerUniversalLinkCallback(url => {
            this.zone.run(() => {
                console.log(url);
                
                this.router.navigate(["/login"]);
            })
        })
    }
}

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start from the registerUniversalLinkCallback entry point in ngOnInit and reproduce the navigation through this AppComponent code. Trace the callback, NgZone, and router.navigate sequence alongside the reported FragmentManager exception. Done means navigating from a universal link no longer crashes the app.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, angular, typescript
Domain
frontend, mobile-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.