Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-7410] Android: V8: Titanium.Media.Sound: play() fails when sound object is local to an event listener

GitHub Issuen/a
TypeBug
PriorityMedium
StatusClosed
ResolutionInvalid
Resolution Date2012-02-08T14:31:40.000+0000
Affected Version/sRelease 1.8.0.1, Release 1.8.1
Fix Version/sn/a
ComponentsAndroid
Labelsqe-and012312
ReporterDustin Hyde
AssigneeBill Dawson
Created2012-01-25T15:55:23.000+0000
Updated2012-05-18T00:43:11.000+0000

Description

Android: V8: Titanium.Media.Sound: play() fails to play (6 times out of 10) and generates errors when called on an object created in the event listener doing the play() call. Log Attached. In Rhino, sounds play correctly, but there are error messages. Log Attached. In V8, if the sound object is stored in a higher scope, play() works as it does in Rhino. Steps to Reproduce: 1. Run SoundTest app. Project Attached. 2. Press the sound buttons, read the console, listen to the sounds. Expected Result: Sounds should play every time a button is pressed and generate no error messages. Actual Result: Sounds rarely play and generate error messages. Note: Test Case exists in /titanium_mobile_tests_internal/FeatureTest/Media/module_media > TIMOB-5330. Note: Will investigate behavior on more devices in the future.

Attachments

FileDateSize
sound android 4.0 rhino 1.8.1.txt2012-01-25T15:55:23.000+00003947
sounds android 4.0 v8 1.8.1.txt2012-01-25T15:55:23.000+00007257
SoundTest.zip2012-01-25T15:55:23.000+00002326035

Comments

  1. Bill Dawson 2012-02-07

    I've been playing with this now for a while on 2 devices and 1 emulator: Device 1: Model: T-Mobile G-Slate Android: 3.1 Device 2: Model: HTC Desire Android: 2.2 Emulator: Android 2.2 I've been using our master branch (hash 6249fc07), and also 1.8.0.1 for comparison purposes. To me it seems like the behavior is already _much_ improved in master, and indeed there have been fairly recent Sound-related changes. However, it's still not "perfect", but the behavior is basically the same as what I see in a native (non-Titanium) Android application that I built for comparison purposes. With this test Titanium app (and my native Android app which follows the same idea), memory will fairly quickly run out and kill the media player. That's because this test app -- at least for Android -- is pretty crazy. Each time you click a button, an entirely new [Android MediaPlayer](http://developer.android.com/reference/android/media/MediaPlayer.html) instance is created and prepared (because our createSound is called each time), without any of the previous ones being release'd. This is madness (in Android, anyway), and hopefully not a real-world way that someone is writing an app. If it works fine in iOS, then maybe iOS has a lighter-weight way (or simply better performing, less memory-eating way) of playing sounds: meaning, better than Android's MediaPlayer. In a real app, I would hope our Sound proxy instances would be re-used rather than re-created every time. Anyway: @DUSTIN, can you run some tests against master (1.9.0) and see if the behavior is indeed better, as I described? If so, I think you would probably want to close this. I've spent a long time examining our code and comparing it to a native Android app's similar code, and I don't believe we're doing anything different than would be expected.
  2. Dustin Hyde 2012-02-08

    Tested with: SDK: 1.8.0.1 githash=fbdc96f, 1.9.0.v20120207171634 Android: V8 Studio: 1.0.8.201201262211 OS: Lion Devices Tested: iPhone4 5.0.1, Droid3 2.3.4, Nexus One 2.2.2 Results: The 1.9.0 behavior is similar/identical to the older 1.8.0.1 behavior. The sound object is not being used properly. Closing issue as invalid. Changed code to re-use sound objects, opening new issue for iOS/Android sound performance.

JSON Source