ubuntu-phone team mailing list archive
-
ubuntu-phone team
-
Mailing list archive
-
Message #01767
Re: Running QML functions in parallel thread
FYI: After having a chat with the SDK people, it turns out that the Button is
indeed slower than it should be. I've reported this bug:
https://bugs.launchpad.net/ubuntu-ui-toolkit/+bug/1170638
Br,
Michael
On Thursday 18 April 2013 20:05:59 Michael Zanetti wrote:
> Wow, the slowness really comes from using the Button element from
> Ubuntu.Components.
>
> Inside GameButton.qml, replace Button {} with this:
>
> Image
> {
> id: button
> source: "closed.png"
> width: buttonHolder.width
> height: buttonHolder.height
>
> MouseArea {
> anchors.fill: parent
> onClicked:
> {
> console.log("(" + row + ", " + column + ")")
> buttonClicked(row, column)
> }
> }
> }
>
>
> and it'll be _much_ faster. I tend to say this is an issue in the Button
> component. On the other hand its probably not supposed to be used 256 times
> on one page as it requires lots of theming stuff which you don't really
> need in your game.
>
> What do the SDK people think of this?
>
> Br,
> Michael
>
> On Thursday 18 April 2013 19:28:29 Николай Шатохин wrote:
> > This is my git repository:
> >
> > https://bitbucket.org/nshatokhin/valves.git
> >
> > And how to connect signals to buttons created by Repeater?
> >
> >
> > 2013/4/18 Michael Zanetti <michael.zanetti@xxxxxxxxxxxxx>
> >
> > > Doesn't look too bad... so the slowness must be either in the GameButton
> > > itself or something connected to the the fieldCreated() signal.
> > >
> > > Can you push the whole code to some repository? I would be willing to
> > > give
> > > it
> > > a shot and try to find out whats going wrong.
> > >
> > > On Thursday 18 April 2013 18:32:53 Николай Шатохин wrote:
> > > > I did this:
> > > > Grid
> > > >
> > > > {
> > > >
> > > > id: grid
> > > >
> > > > anchors.centerIn: parent
> > > >
> > > > rows: 4
> > > >
> > > > columns: 4
> > > >
> > > > spacing: __buttonRightMargin
> > > >
> > > > Repeater
> > > >
> > > > {
> > > >
> > > > id: buttons
> > > >
> > > >
> > > > GameButton
> > > >
> > > > {
> > > >
> > > > row: index % __gameFieldWidth
> > > >
> > > > column: index / __gameFieldWidth
> > > >
> > > > width: __buttonWidth
> > > >
> > > > height: __buttonHeight
> > > >
> > > > }
> > > >
> > > > }
> > > >
> > > > }
> > > >
> > > >
> > > > onCreateField:
> > > >
> > > > {
> > > >
> > > > grid.rows = fieldHeight;
> > > >
> > > > grid.columns = fieldWidth;
> > > >
> > > > buttons.model = fieldWidth * fieldHeight;
> > > >
> > > >
> > > > fieldCreated(fieldWidth, fieldHeight);
> > > >
> > > > }
> > > >
> > > > Now, I don't see buttons from old field if I start new game with
> > > > smaller field, but it still so slow.
> > > >
> > > >
> > > >
> > > > 2013/4/16 Николай Шатохин <n.shatokhin@xxxxxxxxx>
> > > >
> > > > > Nope, but very similar by interface
> > > > >
> > > > >
> > > > > 2013/4/16 Roman Shchekin <mrqtros@xxxxxxxxx>
> > > > >
> > > > >> MineSweeper?
> > > > >>
> > > > >>
> > > > >> 2013/4/16 Michael Zanetti <michael.zanetti@xxxxxxxxxxxxx>
> > > > >>
> > > > >>> On Tuesday 16 April 2013 18:54:01 Michael Zanetti wrote:
> > > > >>> > As a rule of thumb, you should be able to write more than 90% of
> > >
> > > your
> > >
> > > > >>> > application without the need to the work "function" (game logic
> > > > >>>
> > > > >>> excluded).
> > > > >>>
> > > > >>> That should have been: ... without the need to use the word
> > > > >>> "function"...
> > > > >>>
> > > > >>> Regards,
> > > > >>> Michael
> > > > >>>
> > > > >>> > > 2013/4/16 Rick Spencer <rick.spencer@xxxxxxxxxxxxx>
> > > > >>> > >
> > > > >>> > > > I suppose you would use a loader for the Repeater. After you
> > >
> > > make
> > >
> > > > >>> your
> > > > >>>
> > > > >>> > > > repeater work for your first level, you can use QtCreator to
> > >
> > > wrap
> > >
> > > > >>> the
> > > > >>>
> > > > >>> > > > Repeater in a loader for you. Then I think for each level
> > > > >>> > > > you
> > > > >>> > > > would
> > > > >>> > > > destroy the whole Repeater and then use the loader to create
> > > > >>> > > > a
> > >
> > > new
> > >
> > > > >>> one
> > > > >>>
> > > > >>> > > > with the new model for the next level.
> > > > >>> > > >
> > > > >>> > > > At least that is the approach I would take starting out.
> > > > >>> > > >
> > > > >>> > > > HTH
> > > > >>> > > >
> > > > >>> > > > Cheers, Rick
> > > > >>> > > >
> > > > >>> > > > On Tue, Apr 16, 2013 at 7:31 AM, Николай Шатохин <
> > > > >>>
> > > > >>> n.shatokhin@xxxxxxxxx>
> > > > >>>
> > > > >>> > > > wrote:
> > > > >>> > > > > When I create button I assign destroy signal to each. So,
> > >
> > > when I
> > >
> > > > >>> start
> > > > >>>
> > > > >>> > > > new
> > > > >>> > > >
> > > > >>> > > > > game, I destroying buttons from old game and see old field
> > > > >>> > > > > in
> > > > >>>
> > > > >>> this
> > > > >>>
> > > > >>> > > > moment -
> > > > >>> > > >
> > > > >>> > > > > destroing slow too. Is quickly removing possible? Can I
> > >
> > > destroy
> > >
> > > > >>> > > > > repeater?
> > > > >>> > > > >
> > > > >>> > > > >
> > > > >>> > > > > 2013/4/16 Николай Шатохин <n.shatokhin@xxxxxxxxx>
> > > > >>> > > > >
> > > > >>> > > > >> Oh, I didn't know that. I'll try.
> > > > >>> > > > >>
> > > > >>> > > > >>
> > > > >>> > > > >> 2013/4/16 Rick Spencer <rick.spencer@xxxxxxxxxxxxx>
> > > > >>> > > > >>
> > > > >>> > > > >>> Hi.
> > > > >>> > > > >>>
> > > > >>> > > > >>> I'm not sure how your code flows overall, but if you are
> > > > >>>
> > > > >>> creating
> > > > >>>
> > > > >>> > > > >>> all
> > > > >>> > > >
> > > > >>> > > > the
> > > > >>> > > >
> > > > >>> > > > >>> buttons at once, you might consider using a Repeater
> > >
> > > instead
> > >
> > > > >>> > > > >>> of
> > > > >>> > > > >>> doing
> > > > >>> > > >
> > > > >>> > > > it all
> > > > >>> > > >
> > > > >>> > > > >>> in javascript.
> > > > >>> > > > >>>
> > > > >>> > > > >>> It looks like you might have some kind of list that
> > > > >>> > > > >>> fires
> > > > >>> > > > >>> a
> > > > >>> > > >
> > > > >>> > > > createButton
> > > > >>> > > >
> > > > >>> > > > >>> signal. You could potentially use that list as a model
> > > > >>> > > > >>> for
> > >
> > > a
> > >
> > > > >>> > > > >>> Repeater
> > > > >>> > > >
> > > > >>> > > > and
> > > > >>> > > >
> > > > >>> > > > >>> build your buttons in the delegate of the Repeater.
> > > > >>> > > > >>>
> > > > >>> > > > >>> Cheers, Rick
> > > > >>> > > > >>>
> > > > >>> > > > >>>
> > > > >>> > > > >>>
> > > > >>> > > > >>> On Tue, Apr 16, 2013 at 5:11 AM, Николай Шатохин <
> > > > >>> > > >
> > > > >>> > > > n.shatokhin@xxxxxxxxx>
> > > > >>> > > >
> > > > >>> > > > >>> wrote:
> > > > >>> > > > >>>> This is my code that creates buttons field:
> > > > >>> > > > >>>>
> > > > >>> > > > >>>>
> > > > >>> > > > >>>> onCreateField:
> > > > >>> > > > >>>> {
> > > > >>> > > > >>>>
> > > > >>> > > > >>>> for(var i=0;i<fieldWidth;i++)
> > > > >>> > > > >>>> {
> > > > >>> > > > >>>>
> > > > >>> > > > >>>> for(var j=0;j<fieldHeight;j++)
> > > > >>> > > > >>>> {
> > > > >>> > > > >>>>
> > > > >>> > > > >>>> createButton(i, j);
> > > > >>> > > > >>>>
> > > > >>> > > > >>>> }
> > > > >>> > > > >>>>
> > > > >>> > > > >>>> }
> > > > >>> > > > >>>>
> > > > >>> > > > >>>> }
> > > > >>> > > > >>>>
> > > > >>> > > > >>>> function createButton(x, y)
> > > > >>> > > > >>>> {
> > > > >>> > > > >>>>
> > > > >>> > > > >>>> __buttonX = x;
> > > > >>> > > > >>>> __buttonY = y;
> > > > >>> > > > >>>>
> > > > >>> > > > >>>> __component = Qt.createComponent("GameButton.qml");
> > > > >>> > > > >>>>
> > > > >>> > > > >>>> if(__component != null)
> > > > >>> > > > >>>>
> > > > >>> > > > >>>> continueButtonCreation();
> > > > >>> > > > >>>>
> > > > >>> > > > >>>> else
> > > > >>> > > > >>>>
> > > > >>> > > > >>>> __component.ready.connect(continueButtonCreatio
> > > > >>> > > > >>>> n)
> > > > >>> > > > >>>> ;
> > > > >>> > > > >>>>
> > > > >>> > > > >>>> }
> > > > >>> > > > >>>>
> > > > >>> > > > >>>> function continueButtonCreation()
> > > > >>> > > > >>>> {
> > > > >>> > > > >>>>
> > > > >>> > > > >>>> var button = __component.createObject(field, {"row":
> > > > >>> __buttonY,
> > > > >>>
> > > > >>> > > > >>>> "column": __buttonX});
> > > > >>> > > > >>>>
> > > > >>> > > > >>>> if (button == null) {
> > > > >>> > > > >>>>
> > > > >>> > > > >>>> // Error Handling
> > > > >>> > > > >>>> console.log("Error creating object");
> > > > >>> > > > >>>>
> > > > >>> > > > >>>> return;
> > > > >>> > > > >>>>
> > > > >>> > > > >>>> }
> > > > >>> > > > >>>>
> > > > >>> > > > >>>> updateValveState.connect(button.stateUpdated);
> > > > >>> > > > >>>> button.buttonClicked.connect(buttonClicked);
> > > > >>> > > > >>>>
> > > > >>> > > > >>>> field.clearField.connect(button.release);
> > > > >>> > > > >>>>
> > > > >>> > > > >>>> }
> > > > >>> > > > >>>>
> > > > >>> > > > >>>>
> > > > >>> > > > >>>> fieldWidth = fieldHeight = 16;
> > > > >>> > > > >>>>
> > > > >>> > > > >>>>
> > > > >>> > > > >>>> 2013/4/16 Alex Tyler <alex.tyler@xxxxxxxxxx>
> > > > >>> > > > >>>>
> > > > >>> > > > >>>>> Can we see some code? The only time Images hang for me
> > > > >>> > > > >>>>> in
> > > > >>>
> > > > >>> QML is
> > > > >>>
> > > > >>> > > > >>>>> when
> > > > >>> > > > >>>>> it's trying to load them synchronously. Try setting
> > > > >>>
> > > > >>> asynchronous
> > > > >>>
> > > > >>> > > > >>>>> to
> > > > >>> > > >
> > > > >>> > > > true.
> > > > >>> > > >
> > > > >>> > > > >>>>> Cheers,
> > > > >>> > > > >>>>> Alex
> > > > >>> > > > >>>>>
> > > > >>> > > > >>>>> On Tue, Apr 16, 2013 at 10:20 AM, <mrqtros@xxxxxxxxx>
> > >
> > > wrote:
> > > > >>> > > > >>>>>> I thought Nick creates 1024 (16x16) buttons, lol =)
> > > > >>> > > > >>>>>> And
> > > > >>>
> > > > >>> even did
> > > > >>>
> > > > >>> > > > >>>>>> not
> > > > >>> > > > >>>>>> thought - for what :D
> > > > >>> > > > >>>>>>
> > > > >>> > > > >>>>>> Of course code is extremely bad, if buttons with size
> > >
> > > 16x16
> > >
> > > > >>> > > > >>>>>> pixels
> > > > >>> > > > >>>>>> creating slowly.
> > > > >>> > > > >>>>>>
> > > > >>> > > > >>>>>>
> > > > >>> > > > >>>>>> 16.04.13 12:09 Michael Zanetti написал(а):
> > > > >>> > > > >>>>>>
> > > > >>> > > > >>>>>> On Tuesday 16 April 2013 01:01:28 Николай Шатохин
>
> wrote:
> > > > >>> > > > >>>>>> > Hello.
> > > > >>> > > > >>>>>> >
> > > > >>> > > > >>>>>> > In my code I'm creating 16x16 buttons in cycle and
> > >
> > > this
> > >
> > > > >>> take
> > > > >>>
> > > > >>> > > > >>>>>> > few
> > > > >>> > > > >>>>>> > seconds.
> > > > >>> > > > >>>>>> > While function that creating buttons runs, app
> > >
> > > freezes. I
> > >
> > > > >>> want
> > > > >>>
> > > > >>> > > > >>>>>> > to
> > > > >>> > > > >>>>>> > show
> > > > >>> > > > >>>>>> > loading animation while this function runs. So, how
> > > > >>> > > > >>>>>> > to
> > > > >>>
> > > > >>> run this
> > > > >>>
> > > > >>> > > > >>>>>> > function in
> > > > >>> > > > >>>>>> > parallel thread to avoid freezing?
> > > > >>> > > > >>>>>> >
> > > > >>> > > > >>>>>> > Best regards,
> > > > >>> > > > >>>>>> > Nick
> > > > >>> > > > >>>>>>
> > > > >>> > > > >>>>>> Creating 16x16 buttons shouldn take a few seconds.
> > > > >>> > > > >>>>>> Can
> > >
> > > you
> > >
> > > > >>> paste
> > > > >>>
> > > > >>> > > > >>>>>> the
> > > > >>> > > > >>>>>> code
> > > > >>> > > > >>>>>> (also the button itself). To me it seems the issue is
> > > > >>>
> > > > >>> somewhere
> > > > >>>
> > > > >>> > > > else,
> > > > >>> > > >
> > > > >>> > > > >>>>>> e.g. in
> > > > >>> > > > >>>>>> the way you create the buttons or the buttens
> > > > >>> > > > >>>>>> themselves
> > > > >>>
> > > > >>> are very
> > > > >>>
> > > > >>> > > > >>>>>> slow.
> > > > >>> > > > >>>>>>
> > > > >>> > > > >>>>>> Br,
> > > > >>> > > > >>>>>> Michael
> > > > >>> > > > >>>>>>
> > > > >>> > > > >>>>>> --
> > > > >>> > > > >>>>>> Mailing list: https://launchpad.net/~ubuntu-phone
> > > > >>> > > > >>>>>> Post to : ubuntu-phone@xxxxxxxxxxxxxxxxxxx
> > > > >>> > > > >>>>>> Unsubscribe : https://launchpad.net/~ubuntu-phone
> > > > >>> > > > >>>>>> More help : https://launchpad.net/~ubuntu-phone
> > > > >>> > > > >>>>>>
> > > > >>> > > > >>>>>>
> > > > >>> > > > >>>>>>
> > > > >>> > > > >>>>>> --
> > > > >>> > > > >>>>>> Mailing list: https://launchpad.net/~ubuntu-phone
> > > > >>> > > > >>>>>> Post to : ubuntu-phone@xxxxxxxxxxxxxxxxxxx
> > > > >>> > > > >>>>>> Unsubscribe : https://launchpad.net/~ubuntu-phone
> > > > >>> > > > >>>>>> More help : https://help.launchpad.net/ListHelp
> > > > >>> > > > >>>>
> > > > >>> > > > >>>> --
> > > > >>> > > > >>>> Mailing list: https://launchpad.net/~ubuntu-phone
> > > > >>> > > > >>>> Post to : ubuntu-phone@xxxxxxxxxxxxxxxxxxx
> > > > >>> > > > >>>> Unsubscribe : https://launchpad.net/~ubuntu-phone
> > > > >>> > > > >>>> More help : https://help.launchpad.net/ListHelp
> > > > >>> > > > >>>
> > > > >>> > > > >>> --
> > > > >>> > > > >>> Mailing list: https://launchpad.net/~ubuntu-phone
> > > > >>> > > > >>> Post to : ubuntu-phone@xxxxxxxxxxxxxxxxxxx
> > > > >>> > > > >>> Unsubscribe : https://launchpad.net/~ubuntu-phone
> > > > >>> > > > >>> More help : https://help.launchpad.net/ListHelp
> > > > >>> > > >
> > > > >>> > > > --
> > > > >>> > > > Mailing list: https://launchpad.net/~ubuntu-phone
> > > > >>> > > > Post to : ubuntu-phone@xxxxxxxxxxxxxxxxxxx
> > > > >>> > > > Unsubscribe : https://launchpad.net/~ubuntu-phone
> > > > >>> > > > More help : https://help.launchpad.net/ListHelp
> > > > >>>
> > > > >>> --
> > > > >>> Mailing list: https://launchpad.net/~ubuntu-phone
> > > > >>> Post to : ubuntu-phone@xxxxxxxxxxxxxxxxxxx
> > > > >>> Unsubscribe : https://launchpad.net/~ubuntu-phone
> > > > >>> More help : https://help.launchpad.net/ListHelp
> > > > >>
> > > > >> --
> > > > >> Mailing list: https://launchpad.net/~ubuntu-phone
> > > > >> Post to : ubuntu-phone@xxxxxxxxxxxxxxxxxxx
> > > > >> Unsubscribe : https://launchpad.net/~ubuntu-phone
> > > > >> More help : https://help.launchpad.net/ListHelp
Follow ups
References