Forums

OverviewV-Play 2 Support (Qt 5) › SoundEffectVPlay performance issue

Tagged: 

Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #8397

    Jan

    I’ve got a game scene with apprx. 15 enemy entities, each containing and playing a SoundEffectVPlay component.

    Those enemies are killed and spawned on a high frequency. Especially on iOS I see a performance issue, as the UI lags, when those entities get killed. Even “pooling” the entities does not relax the situation.

    Obviously the SoundEffectVPlay derives from the Qml SoundEffect Element, which shows the same flaws. The Qt doc says, that SoundEffect Items are to be used carefully and in general an Audio or MediaPlayer item is to be used. But unfortunately those items show issues when trying to load resources(QTBUG-36175).

    Is there a workaround or a fix maybe?

    Thanks in advance,

    drosophila

     

     

     

     

    #8408

    Alex
    V-Play Team

    Hi drosophila,

    did you try using the Audio element and play sounds from the assets folder instead of the resources? We will consider changing the internals of SoundEffectVPlay, as it looks like Qt is not providing a fix for the SoundEffect component soon.

    Cheers,
    Alex

    #8409

    Jan

    Well performance wise the Audio Element works much better. But that element seems to have an issue on iOS, that the volume property has no effect. On Android and mac it works fine…

    And apart of that, if I wanted to publish the game, I would have to put the qml code into the resources, to kinda protect my intellectual property, and deliver my audio content unprotected, as a folder in the bundle, right? Do you have experience in getting that through the app store gates?

     

    Cheers,

    drosophila

    #8419

    Christian
    V-Play Team

    Hi drosophila,

    yes you are right, to protect your IP you can bundle your QML & JS files in a qrc resources file, and put your assets into the assets folder on Android and the app bundle on iOS. We have prepared that for you in V-Play. We allow changing the deployment without you having to worry about path changes (i.e. you do not need to change the file prefix in your qml files!).

    Please have a look at the .pro and main.cpp file of our demos and the wizard files you used to create your project. There you will find a note

    # NOTE: for PUBLISHING, perform the following steps:

    and change the path to the main.qml file in your main.cpp to “qrc:/qml/Main.qml”

    That way, your qml files are protected and sound issues are resolved.

     

    Regarding the audio performance issue, we’ll run a few tests and then change the internals of SoundEffectVPlay to what works best. What is your experience what works best?

    Cheers, Chris

    • This reply was modified 4 years ago by  Christian.
    #8424

    Jan

    Well as always there are pros and cons(just seen so far while fiddling around with it for an hour or so):

    MediaPlayer/Audio:

    • seem to be more resource friendly but not reliable. If you rapidly trigger audio files, sometimes there is no signal being played. What I’ve seen so far volume changes don’t have an effect on iOS; Android seems to be fine
    • and not to forget the bug, that they can not play resource files QTBUG-36175

    SoundEffect:

    • low latency
    • resource hungry
    • and if the Qt docs prove to be right also not reliable when it comes to multi-timbrality (several SoundEffects played simultaneously)
    • and from my own findings: if you create an entity that contains a SoundEffect on iOS, the performance drops drastically, and you can end up with a dropped framerate / sluggish UI update

    I think those type are to diverse to come up with a generally valid conclusion.

     

    Cheers,

    drosophila

    #8425

    Christian
    V-Play Team

    Hi Jan,

    thanks for sharing!

    I think we’ll have to keep the default implementation then – you can use any others of the audio elements of Qt Quick if it better fits your needs.

    Pooling should relax the SoundEffect issues though – are you sure you really are not deleting the entity? (you could add a log output like that in your EntityBase:

    Component.onDestruction: console.log("entity removed", entityId)

     

    Cheers, Chris

    #8427

    Jan

    Hey Chris,

    yes I tried pooling, It definitely relaxed the situation, but start/stop on 10-15 entities with Soundeffects also already teared down the update rate on the iPad.

    And I had issues with pooling:

    • Not so important, but it cluttered my debug output, that I could not see my own debug output anymore(one could see it as a sign of weakness, but I need it on a regular basis :-) )
    • more important, revived entries did not get back their old IDs, in which case the entityManager seems to concatenate the old ID by underscores. This can result in IDs with serveral dozens of underscore. I did not analyze it, but it felt like getting slower over time. And apart of that it additionally clutters the debug output.

    Therefore I did set up my own pool in JavaScript which also allowed me to access all entities in the same event loop. This is actually something, that is missing in your ECS approach: having systems, that can iterate over all entities, that contain certain components.

    #8431

    Christian
    V-Play Team

    Hi Jan,

    I would recommend limiting the simulatenously played SoundEffects to maybe 3-5 to make sure performance is good (to play more simulatenously will probably disturb the user anyway) – you could do that with an own AudioManager for example which just has a play function and does this internally..

     

    Regarding your other points:

    @Logging Debug Output

    We will change the default logging behavior of the engine to be disabled in future updates, while you can then turn them on with categorized logging from Qt. Meanwhile, you can prefix your log output e.g. with “xxx” and then can browse through the log with a search. Not ideal, but a workaround at least. 😉

    @Id Concatenations

    Performance should be the same by concatenating. You should not rely on the id anywhere else than for debug output purposes though. We can change the id pooling naming mechanism – do you think it would be useful, and if so, which naming mechanism would you prefer?

    @Entity Component System

    You can use EntityManager::getEntityArrayByType() to receive all entities of a given entityType. However, the outside should not know about internal components of these Entities – instead, I would recommend a Connection element that listens to a signal in the entity if something of global interest happens.

     

    Do you need something different, or what is your use case?

    Cheers, Chris

    #8442

    Jan

    @Id Concatenations

    In case entities on the back burner would keep their ID, you should be fine, no? I assume the issue arises by reusing the IDs

    @Entity Component System

    let me fiddle around some more; I haven’t quite got a good solution for custom systems in QML; but I remember a talk at the Dev days, where the guys from KDAB introduced Qt3D 2.0; and they had a pretty neat ECS implementation (as far as I can tell from looking at their slides).

     

    Back onTopic:

    I recently faced an issue, that on Android devices SoundEffects after a while of triggering rapidly do not play anymore. I fiddled around alot and checked all status flags. Audio and MediaPlayer show the same actually. For rapid trigger on Android I need to call stop() & play() to work as expected btw…

    I proposed a solution here before, but it was not reliable.

     

    • This reply was modified 4 years ago by  drosophila.
    • This reply was modified 4 years ago by  drosophila.
    #8452

    Christian
    V-Play Team

    Hi Jan,

    @Id Concatenation

    I was thinking about this topic a bit more over the weekend, and think the current solution is fine. The id will be reused if it is not in the existing entities list, and if there already exists an entity with that name, a “_” is appended to show there is a (probably unwanted) duplication of entity ids. Can you maybe post an example how you are using the entity creation and what your expected output would be?

     

    @Entity Component System

    Can you share a link to the slides or the presentation? I didn’t see that one at Dev Days this year.

    What would you like to achieve with the ECS, i.e. what is your use case?

     

    @Audio Performance

    I recommend using 2 or 3 duplicate SoundEffectVPlay items and using a custom Audio Manager, if you need short-lasting audio files that may overlap. That way, you avoid having to stop them and have better performance.

    Cheers, Chris

    #8475

    Jan

    @Audio Performance

    Things can be so simple sometimes…I was trying to get it right the ordinary way, that I did not even think about some kind of ping-pong solution…

    Works perfect for me, thanks!!!

    #8478

    Christian
    V-Play Team

    You’re welcome, good to hear you got it fixed with the little hint :)

    Cheers, Chris

Viewing 12 posts - 1 through 12 (of 12 total)

RSS feed for this thread

You must be logged in to reply to this topic.

Voted #1 for:

  • Easiest to learn
  • Most time saving
  • Best support

Develop Cross-Platform Apps and Games 50% Faster!

  • Voted the best supported, most time-saving and easiest to learn cross-platform development tool
  • Based on the Qt framework, with native performance and appearance on all platforms including iOS and Android
  • Offers a variety of plugins to monetize, analyze and engage users
FREE!
create apps
create games
cross platform
native performance
3rd party services
game network
multiplayer
level editor
easiest to learn
biggest time saving
best support