Software Archive
Read-only legacy content

Crosswalk garbage collection

Tim_A_2
Beginner
490 Views

Hi, I was wondering if there is any way to manually control media resources, such as clearing previous media buffers or controlling how much ram they use? I have a media rich app that runs fine initially but gradually starts to stutter and die on some android tablets, presumably because of a lack of efficient or fast enough garbage collection. I am trying to use a restricted number of audio (html) tags but the problem is still there.

 

thanks,

T

0 Kudos
8 Replies
Amrita_C_Intel
Employee
490 Views

Hello,

See this example: https://github.com/xmnboy/hello-cordova

There is function call media.release which marks the resources for garbage collection.

0 Kudos
Tim_A_2
Beginner
490 Views

Hi Amrita - thank you, that's exactly what I was looking for.  I know this puts me well and truly in the 'should have read the literature first' category, sorry about that!  In my (weak) defence I'm trying to convert an Appcelerator Titanium app and actually went through and deleted all references to 'release()'!  Oh well...

My only problem now is that I can't include the cordova.js file - in the literature it says it's a 'phantom' file that doesn't exist until you build the app, but it isn't including it when I do build the app so I'm sure I'm missing something, this is pretty basic after all!

Thanks,

Tim

 

0 Kudos
Anusha_M_Intel1
Employee
490 Views

Hi Tim,

Cordova.js should be in there when you extract your apk file after build. I just tried on a few samples and they all contain the file. Did you try your app on device? Is it working as it should?

Try the res/raw folder. 

0 Kudos
Tim_A_2
Beginner
490 Views

Hi,

Yes sorry - running the debug with my device, cordova.js must be there as it isn't throwing any errors - however from what I've read, the release() function only works with the native media plugin, which can only play one sound at a time, is that correct?

At the moment I'm using html audio tags to play multi-channel sound.  Basically I have 6 audio tags that I reuse throughout the game, changing src.  It's a mixture of 3-5 minute background music loops, 60-sec ambient loops and short 5-10 speech clips that play simultaneously.  I was hoping that by using just those 6 and changing the source it'd conserve memory, but I'm not sure it really works like that?  It works pretty well otherwise.  There's no need for instant (sound effect) playback, I would use the Web Audio API for that if I needed it, but obviously it's no use for these long clips I'm playing.

Thanks for you help!

T

 

0 Kudos
Amrita_C_Intel
Employee
490 Views

Is your app working now?

0 Kudos
Tim_A_2
Beginner
490 Views

I'm still using HTML audio tags rather than Cordova native media but actually the app seems to be working much better now, probably mainly because I've spent some time redesigning the UI and have removed the need for some large graphic divs and other memory-eating resources, so it's likely these were actually more of a problem than the audio.

If it ain't broke don't fix it I guess!

 

0 Kudos
Anusha_M_Intel1
Employee
490 Views

The only disadvantages ia that HTML5 <audio> tag does not work well in the webviews on many devices. Bu if it works for you well and good :)

Have you tried a low latency media plugin? http://www.tricedesigns.com/2012/01/25/low-latency-polyphonic-audio-in-phonegap/

0 Kudos
Tim_A_2
Beginner
490 Views

Sorry Anusha, just saw your reply - no I haven't tried that plugin yet simply because it's working fine just using HTML audio at the moment, I'm using Crosswalk anyway so there shouldn't be any web view problems.

However I've now run in to another disaster I'm going to ask about on a separate thread - Google Expansion Packs!!

T

 

 

0 Kudos
Reply