NativeScript / NativeScript/nativescript-cli

[Bundle workflow] Breakpoint in linked source not hit in VSCode on lightweight app initial load

Open
#4,812 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

os: android
Dominant language
JavaScript
Stars
1.1k
Forks
204
Avg merge
1d 9h
Merged PRs (30d)
8

Description

Environment
Provide version numbers for the following components (information can be retrieved by running tns info in your project folder or by inspecting the package.json of the project):

  • CLI: rc
  • Cross-platform modules: rc
  • Android Runtime: rc

Describe the bug
Breakpoint in linked tns-core-modules source is not hit in VSCode on initial app start when using a very thin (lightweight) NativeScript app (e.g. created from blank template) even when stopOnEntry is set to true. After initial load debugging works as expected. A workaround proposed by @DimitarTachev is to place a debugger; statement in the beginning of the file-to-debug.

To Reproduce

  1. git clone git@github.com:NativeScript/NativeScript.git
  2. cd NativeScript
  3. tns create bottom-nav-test --template tns-template-blank-ts
  4. cd bottom-nav-test
  5. tns migrate
  6. Open NativeScript folder in VSCode
  7. Replace the contents of bottom-nav-test/app-root.xml with:
<BottomNavigation>
    <TabStrip>
        <TabStripItem title="First"></TabStripItem>
        <TabStripItem title="Second"></TabStripItem>
    </TabStrip>

    <TabContentItem>
        <GridLayout>
            <Label text="First View" />
        </GridLayout>
    </TabContentItem>

        <TabContentItem>
        <GridLayout>
            <Label text="Second View" />
        </GridLayout>
    </TabContentItem>
</BottomNavigation>
  1. Place a breakpoint in the OnLoaded() method in tns-core-modules/ui/bottom-navigation/bottom-navigation.android.ts
  2. Configure NativeScript debugging and add the following debug configuration in launch.json:
        {
            "name": "bottom-nav | Launch on Android",
            "type": "nativescript",
            "request": "launch",
            "platform": "android",
            "appRoot": "${workspaceRoot}/bottom-nav-test",
            "sourceMaps": true,
            "stopOnEntry": true,
            "watch": true
        },
  1. Try to debug using the newly added configuration
  2. Breakpoint in OnLoaded() is not hit

Expected behavior
Breakpoints should work on initial app start as well

Contributor guide

Open the contributing guide

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

Reproduce the lightweight Android app using the listed NativeScript commands, then start with tns-core-modules/ui/bottom-navigation/bottom-navigation.android.ts and the stopOnEntry configuration in launch.json. Trace the initial startup and source-map debugging flow to determine why OnLoaded() is skipped, using the debugger workaround as a comparison. Done means the breakpoint is hit during initial app load without adding debugger;.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, javascript, typescript, vscode
Domain
cli, developer-experience, mobile-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.