Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Frame crashes on app restore occasionally #715

Closed
sitefinitysteve opened this issue Sep 11, 2015 · 20 comments
Closed

Frame crashes on app restore occasionally #715

sitefinitysteve opened this issue Sep 11, 2015 · 20 comments
Assignees
Milestone

Comments

@sitefinitysteve
Copy link
Contributor

If I leave my app open, then come back to it later it crashes with this??

https://goo.gl/photos/Z8pJyrY8w8nNM9Uf6

... It's always done this

@Kamilius
Copy link

I have exactly the same issue on Android.

  • App is running
  • I'm pressing "home" button to suspend it
  • Opening Chrome and navigating to any page
  • Opening app manager
  • Choosing running NS application
  • Getting error screen with a stack trace:
    quickmemo _2015-09-12-11-00-12

Sadly I don't know how to copy a full stack trace in this situation.
@sitefinitysteve gave only screenshot of first lines of actual stacktrace part of this log.

Funny thing, that it is hard to reproduce if you simply suspending app, without running different ones. For example, If I'm locking/unlocking phone or simply navigating it, mostly - everything's great. But when it comes to launching different apps - it crashes with error above.

When I've tried to debug it using node-inspector and placing a callbacks for all App Events except already handled suspend/resume, node-inspector is simply detaching somewhere upon 'Chrome' step described above.

Any clues on how to copy a full stack trace or fixing this issue?

I'm using nativescript-cli on Ubuntu 14.04 with real device.

@sitefinitysteve
Copy link
Contributor Author

I am unable to replicate via those steps 100% of the time, however I did try to get a full stack trace by using the app analytics module of the telerik platform...app crashed twice on a demo, nothing logged.

application.on(application.uncaughtErrorEvent, function (args) {
    var exception;

    if (args.android)
        exception = args.android;
    else if (args.ios)
        exception = args.ios;

    monitor.trackException(exception, "Uncaught exception");
});

@x4080
Copy link

x4080 commented Sep 30, 2015

I think I have a way to replicate the situation ,in the developers option , set background process limit to 2 or 1, open ns app , go to another app or two then go to the ns app. If the ns app is restarted it will crash as the above picture ( using real device here )

@Kamilius
Copy link

Kamilius commented Oct 1, 2015

@x4080 👍 awesome. It really was crashing upon app restart. Didn't knew that on android dev options is such option, like limiting processes.

And that actually works 100% of time

Also, I think that this situation should've been able to be handled by at least - "lowMemory" or "uncaughtError" application events, but it's not.

@x4080
Copy link

x4080 commented Oct 1, 2015

Glad it can help a bit..the Google search and stackoverflow talked about manifest app name setting but i still cannot resolve it. Maybe other people csn help

@AntonioCuevaUrraco
Copy link

+1 I would love to figure out a way to solve this issue as it is happening quite often.

@x4080
Copy link

x4080 commented Oct 9, 2015

I think it needs high priority also

@blagoev blagoev added this to the 1.5 (Under Review) milestone Oct 9, 2015
@blagoev
Copy link
Contributor

blagoev commented Oct 9, 2015

raised the priority. We will investigate this further as part of 1.5 work.

@x4080
Copy link

x4080 commented Oct 9, 2015

Thanks man

@x4080
Copy link

x4080 commented Oct 11, 2015

I think the problem is in frame.android.ts (PageFragmentBody), android complains about the constructor is not public and have no empty constructor, I tried to change the constructor without parameters and calling new PageFragmentBody with :

    var newFragment = new PageFragmentBody();
    newFragment.frame = this;
    newFragment.entry = backstackEntry;

(the constructor) :

class PageFragmentBody extends android.app.Fragment {
public frame: Frame;
public entry: definition.BackstackEntry;

public  constructor() {
    super();
    return global.__native(this);
}

It still the same result, maybe because class generated is not public ? How can we make inherited class in nativescript public ?

@hamorphis
Copy link
Contributor

Starting work on it...

@hamorphis
Copy link
Contributor

I managed to reproduce it. Go to the App Manager (the thing that has the RAM tab), go to "RAM" and hit the "Clear Memory" button to run the Low Memory Killer (LMK). Then go back to the app. I changed the code so that the PageFragmentBody now has a default empty constructor and is created via a static method called newInstance (as described here), but the Android runtime still can't find the default constructor of PageFragmentBody and crashes with the same exception. Here is the new source code. Maybe the Android runtime guys (@blagoev) will be able to help here. There is an issue in the Android Runtime repo: NativeScript/android#241

@hamorphis
Copy link
Contributor

Just pasting the Java code that leads to this exception. Fragment.java:

    public static Fragment instantiate(Context context, String fname, @Nullable Bundle args) {
        try {
            Class<?> clazz = sClassMap.get(fname);
            if (clazz == null) {
                // Class not found in the cache, see if it's real, and try to add it
                clazz = context.getClassLoader().loadClass(fname);
                if (!Fragment.class.isAssignableFrom(clazz)) {
                    throw new InstantiationException("Trying to instantiate a class " + fname
                            + " that is not a Fragment", new ClassCastException());
                }
                sClassMap.put(fname, clazz);
            }
            Fragment f = (Fragment)clazz.newInstance();
            if (args != null) {
                args.setClassLoader(f.getClass().getClassLoader());
                f.mArguments = args;
            }
            return f;
        } catch (ClassNotFoundException e) {
            throw new InstantiationException("Unable to instantiate fragment " + fname
                    + ": make sure class name exists, is public, and has an"
                    + " empty constructor that is public", e);
        } catch (java.lang.InstantiationException e) {
            throw new InstantiationException("Unable to instantiate fragment " + fname
                    + ": make sure class name exists, is public, and has an"
                    + " empty constructor that is public", e);
        } catch (IllegalAccessException e) {
            throw new InstantiationException("Unable to instantiate fragment " + fname
                    + ": make sure class name exists, is public, and has an"
                    + " empty constructor that is public", e);
        }
    }

@blagoev
Copy link
Contributor

blagoev commented Oct 22, 2015

Ok managed to reproduce this. Will be back with more info what is the issue.

@lscown
Copy link

lscown commented Nov 5, 2015

Any update on this?

@hshristov hshristov assigned hshristov and unassigned hamorphis Nov 6, 2015
@hshristov
Copy link
Contributor

Hi guys,

We have fixed this issue and it will be included in 1.6 release.

@hshristov hshristov added ready for test TSC needs to test this and confirm against live production apps and automated test suites and removed in progress labels Nov 6, 2015
@x4080
Copy link

x4080 commented Nov 6, 2015

Thumbs up..1.5 already finished?

@sitefinitysteve
Copy link
Contributor Author

@hshristov Yeah is this a typo? Did you mean 1.5? I see the version has been incrimented to 1.5, but this is a pretty critical bug to push back to December or later.

@hshristov
Copy link
Contributor

@sitefinitysteve Yeah typo on my side. Sorry. I meant 1.5

@vchimev vchimev added done and removed backlog ready for test TSC needs to test this and confirm against live production apps and automated test suites labels Nov 13, 2015
@vchimev vchimev closed this as completed Nov 13, 2015
@lock
Copy link

lock bot commented Aug 30, 2019

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.

@lock lock bot locked and limited conversation to collaborators Aug 30, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

10 participants