Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
Contributor
craigmj
Posts: 13
Registered: ‎10-01-2011
My Device: 9900
My Carrier: MTN
Accepted Solution

WebView with NavigationPane

I have run into a problem using WebView's with NavigationPane's, and have reduced it to a simple example demonstrating the problem.

Basically, if I push a Page containing a WebView onto a NavigationPane, when I close my App, the App doesn't close properly. On the device, it closes, although it sometimes delays. On the simulator, I have to restart the simulator before I can run my App again.

I have reduced it to this simple demonstration:

1. I start a new Empty Cascades project, let's call it NavEg2, and I set my 'main.qml' to this:

    import bb.cascades 1.0
    NavigationPane {
        Page {
            Container {
                layout: DockLayout {}
                Button {
                    objectName: "clickButton"
                    text: "news.ycombinator.com"
                }
            }
        }
    }

2. I create a 'webpane.qml' in my `assets` folder that looks like this:

    import bb.cascades 1.0
    Page {
        Container {
            WebView {
                url: "http://news.ycombinator.com"
            }
        }
    }

3. I modify my NavEg2.hpp to:

    #ifndef NavEg2_HPP_
    #define NavEg2_HPP_

    #include <QObject>
    #include <bb/cascades/NavigationPane>

    namespace bb { namespace cascades { class Application; }}

        class NavEg2 : public QObject
        {
            Q_OBJECT
            bb::cascades::NavigationPane *root;
        public:
            NavEg2(bb::cascades::Application *app);
            virtual ~NavEg2() {}
            Q_SLOT void buttonClicked();
        };

    #endif /* NavEg2_HPP_ */

3. And I set my NavEg2.cpp to:

    #include "NavEg2.hpp"

    #include <bb/cascades/Application>
    #include <bb/cascades/QmlDocument>
    #include <bb/cascades/Button>

    using namespace bb::cascades;

    NavEg2::NavEg2(bb::cascades::Application *app)
    : QObject(app)
    {
        QmlDocument *qml = QmlDocument::create("asset:///main.qml").parent(this);
        root = qml->createRootObject<NavigationPane>();
        Button *btn = root->findChild<Button*>("clickButton");
        connect(btn, SIGNAL(clicked()), this, SLOT(buttonClicked()));
        app->setScene(root);
    }

    void
    NavEg2::buttonClicked() {
        QmlDocument *qml = QmlDocument::create("asset:///webpane.qml").parent(this);
        root->push(qml->createRootObject<Page>());
    }

Then I set my Build Configuration to Simulator-Debug, build the project, and create a Run Configuration to run it on the Simulator.

When it runs on the Simulator, it works as expected, but when I close the App, it doesn't close. The icon goes 'grayed out', and I can't run the App again without restarting the Simulator. If I don't click the Button - ie if I don't open the WebView - then it closes fine. So I am somehow not using the WebView properly within the NavigationPane.

When I run this on the Dev Alpha device, it takes a while for the App to close (about 5 seconds), but it does eventually close. This makes me think there are some WebView threads doing something, or the device is just much crueller in killing off apps...

Does anyone have any ideas?

Help much appreciated,
Craig

Please use plain text.
Developer
bcs925
Posts: 262
Registered: ‎07-13-2012
My Device: PlayBook, DA B, DA C, LE Z10 #102, Q10, Z30
My Carrier: T-Mobile

Re: WebView with NavigationPane

This is a known bug, hopefully it gets fixed by launch.

 

However for now (and you testing your apps) you don't have to restart the simulator, there is a way to have Momentics kill the process, the proceedure is described here: http://supportforums.blackberry.com/t5/Cascades-Development/Beta-4-WebView-app-freeze-post-exit/td-p...

 


peter9477 wrote:
In Momentics, go to the QNX System Information Perspective. Make sure you're connected to your target device or simulator, and look at the System Summary tab.  You should see your "stuck" process listed there. 

 

Right-click on it and select "Deliver Signal...".  The default is SIGTERM, and that's the one we want. Click OK and a moment later your app should have been "slayed" and the icon will return to the normal state, letting you re-launch the app.




---
Check out my BB10 Cascades Coding site: BBcascades.com & Cascades Blog: bbcascadescode.tumblr.com

My Built for BlackBerry app: The Dive Plan
Please use plain text.
Contributor
craigmj
Posts: 13
Registered: ‎10-01-2011
My Device: 9900
My Carrier: MTN

Re: WebView with NavigationPane

Hi Brian,

 

That's awesome news - had been worried I was doing something wrong. Many thanks,

 

C

Please use plain text.