Skip to content

Resuming Activity from Camera Activity crashes when ListView is on the page. #4584

@bradmartin

Description

@bradmartin

Did you verify this is a real problem by searching Stack Overflow and the other open issues in this repo?

Yes

Which platform(s) does your issue occur on?

Android confirmed on 7.0 (emulator & device)

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

┌──────────────────┬─────────────────┬────────────────┬─────────────┐
│ Component        │ Current version │ Latest version │ Information │
│ nativescript     │ 3.1.2           │ 3.1.2          │ Up to date  │
│ tns-core-modules │ 3.1.0           │ 3.1.0          │ Up to date  │
│ tns-android      │ 3.1.1           │ 3.1.1          │ Up to date  │
│ tns-ios          │ 3.1.0           │ 3.1.0          │ Up to date  │
└──────────────────┴─────────────────┴────────────────┴─────────────┘

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

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

HTML

<action-bar-back [title]="event?.name"></action-bar-back>

<!-- <StackLayout>
    <Button text="PIC" (tap)="takePhoto()"></Button>

</StackLayout> -->
<GridLayout rows="auto, *" columns="*">

    <StackLayout row="0" col="0">
        <Label [text]="event.description" class="h3 text-blue-grey" textWrap="true"></Label>
        <Label [text]="event.address" class="h3" textWrap="true"></Label>
    </StackLayout>

    <!-- <Label row="0" rowSpan="2" col="0" *ngIf="images.length == 0" text="No images for this event yet. Tap the camera button below to start adding images to the event."
        class="h3 text-center p-t-10" verticalAlignment="center" textWrap="true"></Label> -->

    <ListView row="1" col="0" [items]="images" (itemLoading)="onItemLoading($event)" (itemTap)="onItemTap($event)" class="list-group">
        <ng-template let-item="item">
            <!-- <GridLayout rows="auto, auto" columns="auto, *, auto" class="list-group-item">
                <Image row="0" col="0" colSpan="3" height="150" [src]="item.imageUrl" stretch="aspectFit"></Image>
                <Label row="1" col="0" colSpan="3" class="h3 text-blue-grey pull-right" [text]="item.photographer" textWrap="true"></Label>
            </GridLayout> -->
            <StackLayout rows="auto, auto" columns="auto, *, auto" class="list-group-item">
                <Image row="0" col="0" colSpan="3" height="150" [src]="item.imageUrl" stretch="aspectFit"></Image>
                <Label row="1" col="0" colSpan="3" class="h3 text-blue-grey pull-right" [text]="item.photographer" textWrap="true"></Label>
            </StackLayout>
        </ng-template>
    </ListView>

    <FAB row="0" rowSpan="2" col="0" (tap)="takePhoto()" icon="res://ic_photo_camera_white" rippleColor="#f1f1f1" class="take-picture-fab-button"></FAB>

</GridLayout>

If you open the stock camera (using the nativescript-camera plugin) and then close the camera activity this will throw an exception and I'm led to believe it's the GridLayout that is the reason (it's in the exception 😄 ) The important piece here is this page will load fine when you're navigating within the NS app, but once you launch the camera activity and close it is when you'll get the exception. I'm still learning the ng bits with NS so if I'm making a silly mistake apologies in advance 😄. I also haven't seen this type of issue with a plain NS app but haven't confirmed with the same runtime/modules versions.

Exception:

An uncaught Exception occurred on "main" thread.
java.lang.NullPointerException: Attempt to invoke virtual method 'int android.view.View.getVisibility()' on a null object reference
	at android.widget.FrameLayout.layoutChildren(FrameLayout.java:275)
	at android.widget.FrameLayout.onLayout(FrameLayout.java:261)
	at android.view.View.layout(View.java:19393)
	at android.view.ViewGroup.layout(ViewGroup.java:6022)
	at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323)
	at android.widget.FrameLayout.onLayout(FrameLayout.java:261)
	at android.view.View.layout(View.java:19393)
	at android.view.ViewGroup.layout(ViewGroup.java:6022)
	at org.nativescript.widgets.CommonLayoutParams.layoutChild(CommonLayoutParams.java:222)
	at org.nativescript.widgets.GridLayout.onLayout(GridLayout.java:353)
	at android.view.View.layout(View.java:19393)
	at android.view.ViewGroup.layout(ViewGroup.java:6022)
	at org.nativescript.widgets.CommonLayoutParams.layoutChild(CommonLayoutParams.java:222)
	at org.nativescript.widgets.ContentLayout.onLayout(ContentLayout.java:73)
	at android.view.View.layout(View.java:19393)
	at android.view.ViewGroup.layout(ViewGroup.java:6022)
	at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323)
	at android.widget.FrameLayout.onLayout(FrameLayout.java:261)
	at android.view.View.layout(View.java:19393)
	at android.view.ViewGroup.layout(ViewGroup.java:6022)
	at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1791)
	at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1635)
	at android.widget.LinearLayout.onLayout(LinearLayout.java:1544)
	at android.view.View.layout(View.java:19393)
	at android.view.ViewGroup.layout(ViewGroup.java:6022)
	at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323)
	at android.widget.FrameLayout.onLayout(FrameLayout.java:261)
	at com.android.internal.policy.DecorView.onLayout(DecorView.java:736)
	at android.view.View.layout(View.java:19393)
	at android.view.ViewGroup.layout(ViewGroup.java:6022)
	at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:2480)
	at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2199)
	at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1385)
	at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6722)
	at android.view.Choreographer$CallbackRecord.run(Choreographer.java:886)
	at android.view.Choreographer.doCallbacks(Choreographer.java:698)
	at android.view.Choreographer.doFrame(Choreographer.java:633)
	at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:872)
	at android.os.Handler.handleCallback(Handler.java:769)
	at android.os.Handler.dispatchMessage(Handler.java:98)
	at android.os.Looper.loop(Looper.java:164)
	at android.app.ActivityThread.main(ActivityThread.java:6540)
	at java.lang.reflect.Method.invoke(Native Method)
	at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)

Simply remove the gridlayout and loading a stack-layout on the page will not throw the exception.

deps:

 "dependencies": {
    "@angular/animations": "~4.1.0",
    "@angular/common": "~4.1.0",
    "@angular/compiler": "~4.1.0",
    "@angular/core": "~4.1.0",
    "@angular/forms": "~4.1.0",
    "@angular/http": "~4.1.0",
    "@angular/platform-browser": "~4.1.0",
    "@angular/platform-browser-dynamic": "~4.1.0",
    "@angular/router": "~4.1.0",
    "email-validator": "1.0.7",
    "moment": "^2.18.1",
    "nativescript-angular": "~3.1.1",
    "nativescript-camera": "^3.0.1",
    "nativescript-custom-entitlements": "^0.2.0",
    "nativescript-dom": "^2.0.0",
    "nativescript-drop-down": "^3.1.0",
    "nativescript-feedback": "^1.0.5",
    "nativescript-floatingactionbutton": "^3.0.0",
    "nativescript-geolocation": "^3.0.0",
    "nativescript-google-maps-sdk": "^2.3.2",
    "nativescript-gradient": "^2.0.0",
    "nativescript-imagepicker": "^3.0.2",
    "nativescript-loading-indicator": "^2.3.2",
    "nativescript-ngx-fonticon": "^2.2.1",
    "nativescript-plugin-firebase": "^4.0.3",
    "nativescript-telerik-ui-pro": "file:./NativeScriptUIPro/nativescript-ui-pro.tgz",
    "nativescript-theme-core": "~1.0.4",
    "nativescript-toasty": "^1.1.5",
    "reflect-metadata": "~0.1.8",
    "rxjs": "~5.3.0",
    "tns-core-modules": "~3.1.0",
    "zone.js": "~0.8.2"
  },
  "devDependencies": {
    "@angular/compiler-cli": "~4.1.2",
    "@ngtools/webpack": "1.3.1",
    "babel-traverse": "6.4.5",
    "babel-types": "6.4.5",
    "babylon": "6.4.5",
    "copy-webpack-plugin": "~4.0.1",
    "extract-text-webpack-plugin": "~2.1.0",
    "husky": "^0.13.4",
    "lazy": "1.0.11",
    "lint-staged": "^4.0.0",
    "nativescript-css-loader": "~0.26.1",
    "nativescript-dev-sass": "^1.2.0",
    "nativescript-dev-typescript": "~0.5.0",
    "nativescript-dev-webpack": "^0.6.3",
    "prettier": "^1.4.4",
    "raw-loader": "~0.5.1",
    "resolve-url-loader": "~2.0.2",
    "tslint": "5.5.0",
    "typescript": "~2.3.2",
    "webpack": "~2.5.1",
    "webpack-sources": "~0.2.3"
  },

Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions