FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

fix(ios delegate) Eliminate crash on selector looking for "Window" by NathanaelA · Pull Request #6428 · NativeScript/NativeScript · GitHub

fix(ios delegate) Eliminate crash on selector looking for "Window" - #6428

Merged
vakrilov merged 6 commits into
NativeScript:masterfrom
NathanaelA:UIResponder-window
Dec 14, 2018
Merged

vakrilov merged 6 commits into
NativeScript:masterfrom
NathanaelA:UIResponder-window

Conversation

NathanaelA commented Oct 18, 2018 •
edited
Loading

Copy link
Copy Markdown
Contributor

PR Checklist

What is the current behavior?

NS Will crash on some plugins when they attempt to get the "window" from the main delegate. With the error message Application terminated which can't be caught.

What is the new behavior?

NS won't crash anymore

Fixes/Implements/Closes # NativeScript/ios-jsc#430

Notes:
I am not 100% sure if I need to return a valid window, or if undefined is enough. If you believe I should pre-set the window, I'm willing to update the PR if you can point me at which of our "windows" we should return. However, in the plugin I was converting -- I just had to have a valid selector; once I had a property the selector could access; all the random crashes about the missing selector stopped, even though the plugin was always getting "undefined" as the result back. Having the selector was all that is needed to fix this issue for the plugin I was working on making work in NS.

ghost added the ♥ community PR label Oct 18, 2018

vakrilov commented Nov 2, 2018

Copy link
Copy Markdown
Contributor

Hi and thanks for the PR!

The team have been quite busy baking the upcoming NativeScript 5.0 release. We hope you love it as much as we do! The major release is the reason we taking longer with PR reviews. We will resume active reviewing in the following weeks.

Thanks for your patience and for being awesome contributor!

//
}
// Must use .extend() to make the "window" be a valid iOS selector
var Responder = UIResponder.extend({

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Can you refactor this code to use TypeScript extend. It will be more like the rest of the codebase. Should look something like:

class Responder extends UIResponder implements UIApplicationDelegate {
    public static ObjCProtocols = [UIApplicationDelegate];

    private _window: UIWindow;

    get window(): UIWindow {
        return this._window;
    }
    set window(setWindow: UIWindow) {
        this._window = setWindow;
    }
}

This comment was marked as abuse.

This comment was marked as abuse.

NathanWalker Nov 21, 2018 •
edited
Loading

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

@vakrilov It's true - the standard TypeScript version does cause issues due to what @mbektchiev points out in that issue - recently ran into that and was surprised as well. His suggestion there to use .extend works great though.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I guess that the reason is related to another issue we recently discovered in the runtime: NativeScript/ios-jsc#1012. My guess is that if you implement the methods with 2 functions named window and setWindow they should be correctly callable from native.

Copy link
Copy Markdown
Contributor

Thanks for the PR!
About the window question. I would suggest doing:

    get window(): UIWindow {
        return iosApp ? iosApp.window : undefined;
    }

Not sure if the setter should do anything - probably not.

vakrilov self-assigned this Nov 20, 2018
ghost added in progress and removed ♥ community PR labels Nov 20, 2018

Copy link
Copy Markdown
Contributor

Hey @NathanaelA
Any progress on this PR - do you think the comments make sense?

Copy link
Copy Markdown
Contributor

test

vakrilov merged commit 1989594 into NativeScript:master Dec 14, 2018
ghost removed the in progress label Dec 14, 2018

lock Bot commented Jan 9, 2020

Copy link
Copy Markdown

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 Bot locked and limited conversation to collaborators Jan 9, 2020
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants


Back | FazBrowse Home | New Git URL