{ "id": "102587", "key": "TIMOB-13150", "fields": { "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false }, "project": { "id": "10153", "key": "TIMOB", "name": "Titanium SDK/CLI", "projectCategory": { "id": "10100", "description": "Titanium and related SDKs used in application development", "name": "Client" } }, "fixVersions": [ { "id": "15597", "description": "2013 Sprint 17", "name": "2013 Sprint 17", "archived": true, "released": true, "releaseDate": "2013-08-23" }, { "id": "15599", "description": "2013 Sprint 17 API", "name": "2013 Sprint 17 API", "archived": true, "released": true, "releaseDate": "2013-08-23" }, { "id": "14982", "description": "Release 3.2.0", "name": "Release 3.2.0", "archived": false, "released": true, "releaseDate": "2013-12-19" } ], "resolution": { "id": "1", "description": "A fix for this issue is checked into the tree and tested.", "name": "Fixed" }, "resolutiondate": "2013-08-22T20:39:34.000+0000", "created": "2012-10-03T15:36:48.000+0000", "priority": { "name": "Medium", "id": "3" }, "labels": [ "exalture", "module_media", "qe-testadded", "triage" ], "versions": [], "issuelinks": [ { "id": "33502", "type": { "id": "10122", "name": "Gantt: start-finish", "inward": "is triggered by", "outward": "is triggering" }, "outwardIssue": { "id": "91637", "key": "TIMOB-9065", "fields": { "summary": "Android: Sound - Remote URL does not play", "status": { "description": "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.", "name": "Closed", "id": "6", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "priority": { "name": "Critical", "id": "1" }, "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false } } } } ], "assignee": { "name": "sunila", "key": "sunila", "displayName": "Sunila", "active": true, "timeZone": "Asia/Kolkata" }, "updated": "2014-02-14T09:55:24.000+0000", "status": { "description": "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.", "name": "Closed", "id": "6", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "components": [ { "id": "10202", "name": "Android", "description": "Android Platform" } ], "description": "*Problem description*\r\nAudioPlayer.start() freezes the user interface on Android for several seconds (9 seconds and more) until playback starts. I would expect it to be asynchronous (there are events that all one to know what happens...). Or at least it should also have a startAsync(). The url of the AudioPlayer is set to a remote MP3/SHOUTcast stream.\r\n\r\n*Test case*\r\n{code}\r\nvar win = Ti.UI.createWindow({\r\n\tbackgroundColor : \"#FFF\"\r\n});\r\n\r\nvar audioPlayer = Titanium.Media.createAudioPlayer({\r\n\tallowBackground : true\r\n});\r\naudioPlayer.setUrl('http://broadcast.infomaniak.net:80/energyzuerich-high.mp3');\r\nvar s = new Date().getTime();\r\naudioPlayer.start();\r\naudioPlayer.stop();\r\nalert(\"time required: \" + (new Date().getTime() - s));\r\n\r\nwin.open();\r\n{code}", "attachment": [ { "id": "41298", "filename": "app.js", "author": { "name": "billdawson", "key": "billdawson", "displayName": "Bill Dawson", "active": true, "timeZone": "Europe/Berlin" }, "created": "2013-08-05T23:20:07.000+0000", "size": 1066, "mimeType": "text/javascript" } ], "flagged": false, "summary": "Android: AudioPlayer.start() freezes UI thread", "creator": { "name": "remmeier", "key": "remmeier", "displayName": "Remo", "active": true, "timeZone": "America/Los_Angeles" }, "subtasks": [], "reporter": { "name": "remmeier", "key": "remmeier", "displayName": "Remo", "active": true, "timeZone": "America/Los_Angeles" }, "environment": "Android", "comment": { "comments": [ { "id": "228560", "author": { "name": "dsefton", "key": "dsefton", "displayName": "Daniel Sefton", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Apologies for taking so long to reply, but could you possibly provide a test case for us to try out? Thanks!", "updateAuthor": { "name": "dsefton", "key": "dsefton", "displayName": "Daniel Sefton", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2012-11-26T23:45:49.000+0000", "updated": "2012-11-26T23:45:49.000+0000" }, { "id": "229082", "author": { "name": "remmeier", "key": "remmeier", "displayName": "Remo", "active": true, "timeZone": "America/Los_Angeles" }, "body": "A simple example is:\n\nvar audioPlayer = Titanium.Media.createAudioPlayer({allowBackground:true});\naudioPlayer.setUrl('http://broadcast.infomaniak.net:80/energyzuerich-high.mp3');\nvar s = new Date().getTime();\naudioPlayer.start();\naudioPlayer.stop();\nthrow \"time required: \" + (new Date().getTime() - s);\n\nWith Android 4.0, a Samsung Galaxy S2 and a 3G connection the given code blocks for up to nine seconds. If a have a faster WIFI connection, it usually blocks for one to three seconds. Since the AudioPlayer provides a listener to get notified once it has started/stopped, I would expect the methods to return immediately. Maybe a dedicated thread in Android is needed to circumvent the blocking. Have not tested it on iOS.\n\nNine seconds of blocking is quite bad since the entire UI blocks as well.\n", "updateAuthor": { "name": "remmeier", "key": "remmeier", "displayName": "Remo", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2012-11-29T18:58:11.000+0000", "updated": "2012-11-29T18:58:11.000+0000" }, { "id": "231639", "author": { "name": "remmeier", "key": "remmeier", "displayName": "Remo", "active": true, "timeZone": "America/Los_Angeles" }, "body": "In case no data is received from the given url (e.g. the station is temporarly offline), it seems Titanium freezes indefinitely. Android shows a App termination dialog to stop the freezed app. There is no way to stop this. The problem remains with Titanium SDK 3.0. \n\n", "updateAuthor": { "name": "remmeier", "key": "remmeier", "displayName": "Remo", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2012-12-17T15:34:56.000+0000", "updated": "2012-12-17T15:34:56.000+0000" }, { "id": "232320", "author": { "name": "remmeier", "key": "remmeier", "displayName": "Remo", "active": true, "timeZone": "America/Los_Angeles" }, "body": "I had a look at the Titanium source code. In initialize(), one finds on line 124:\n\nmp.prepare(); // Probably need to allow for Async\n\nHere you should at least allow to call mp.prepareAsync(). That will prevent the blocking. You may add a method setAsyncMode(...) to the AudioMediaPlayer. That should be a very small fix. Otherwise, building any kind of streaming app using Titanium is next to impossible.\n \n\n\n", "updateAuthor": { "name": "remmeier", "key": "remmeier", "displayName": "Remo", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2012-12-21T09:48:18.000+0000", "updated": "2012-12-21T09:48:18.000+0000" }, { "id": "243478", "author": { "name": "remmeier", "key": "remmeier", "displayName": "Remo", "active": true, "timeZone": "America/Los_Angeles" }, "body": "What the f**k... \n\nNo possiblity to do any kind of live media streaming application (audio/video) due to unacceptable blocking of the UI by the network stack. A fix would take all of a few lines of codes. Support in Android is available. Still nothing after months of wainting.", "updateAuthor": { "name": "remmeier", "key": "remmeier", "displayName": "Remo", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2013-03-21T18:44:24.000+0000", "updated": "2013-03-21T18:44:24.000+0000" }, { "id": "248159", "author": { "name": "kosso", "key": "kosso", "displayName": "kosso", "active": true, "timeZone": "Europe/London" }, "body": "I'm having this exact issue at the moment while building a live radio app for a client. \r\n\r\nHow can I add this fix? It's been a long long time since I built my own SDK version from git.\r\n\r\nThe app takes far too many seconds to initialize a stream. And also to release it. \r\n\r\nTo change the url property requires a release() of the stream before a start(). This process can take up to 60 seconds which is unacceptable. \r\n\r\n(I notice in my app, I have a clock in the UI, running on a 1 second interval which freezes while this is going on)\r\n\r\n\r\n\r\n", "updateAuthor": { "name": "kosso", "key": "kosso", "displayName": "kosso", "active": true, "timeZone": "Europe/London" }, "created": "2013-04-18T16:34:33.000+0000", "updated": "2013-04-18T16:44:40.000+0000" }, { "id": "249015", "author": { "name": "kosso", "key": "kosso", "displayName": "kosso", "active": true, "timeZone": "Europe/London" }, "body": "@Remo Could you point out which files contain the fix you suggest?\r\n\r\nI would like to try this fix, as the Android radio app I have built is far, far too slow when starting and stopping streams - for the reasons I think you suggest. \r\n\r\nThanks.\r\n\r\n", "updateAuthor": { "name": "kosso", "key": "kosso", "displayName": "kosso", "active": true, "timeZone": "Europe/London" }, "created": "2013-04-25T10:48:16.000+0000", "updated": "2013-04-25T10:48:16.000+0000" }, { "id": "249020", "author": { "name": "rahul002", "key": "rahul002", "displayName": "Rahul Dhingra", "active": true, "timeZone": "America/Los_Angeles" }, "body": "I have studied the issue further. The stream starting slow is a separate issue which is related to a bug in the Android media player itself. Using a stream above 32kbps solves the above 60 sec wait time and makes it leaner towards 6 - 10 seconds on a wifi network. And yes, a higher bitrate stream loads faster....\r\n\r\nThe async issue is a complete bummer though, as its a simple command in the core appcelerator code. The current code says mp.prepare() which simply needs to be switched to mp.prepareAsync()\r\n\r\nIf only I knew how to compile the appcelerator source, this takes a minute to run. For now waiting...\r\n\r\nSee line 124 on:\r\nhttps://github.com/appcelerator/titanium_mobile/blob/master/android/modules/media/src/java/ti/modules/titanium/media/TiSound.java\r\n", "updateAuthor": { "name": "rahul002", "key": "rahul002", "displayName": "Rahul Dhingra", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2013-04-25T13:40:44.000+0000", "updated": "2013-04-25T13:40:44.000+0000" }, { "id": "249021", "author": { "name": "kosso", "key": "kosso", "displayName": "kosso", "active": true, "timeZone": "Europe/London" }, "body": "Hi, \r\n\r\nThanks for looking into this. \r\n\r\nThis old Q&A post instructions for building the Ti SDK is still valid (as far as I can tell)\r\n\r\nhttp://developer.appcelerator.com/question/3931/building-titanium-from-source\r\n\r\nClone the source. Cd to the directory. \r\nrun: scons \r\n\r\n(for platform specific builds only, use scons android=1 or scons iphone=1)\r\n\r\nTo speed up builds, you can disable documentation generation with build_jsca=0\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n", "updateAuthor": { "name": "kosso", "key": "kosso", "displayName": "kosso", "active": true, "timeZone": "Europe/London" }, "created": "2013-04-25T13:49:52.000+0000", "updated": "2013-04-25T13:49:52.000+0000" }, { "id": "249049", "author": { "name": "kosso", "key": "kosso", "displayName": "kosso", "active": true, "timeZone": "Europe/London" }, "body": "I've tried to implement this fix using the master source from github, but the Android SDK build is failing. (Not to do with the fix I think. Something to do with my setup).\r\n\r\nInfuriating. ", "updateAuthor": { "name": "kosso", "key": "kosso", "displayName": "kosso", "active": true, "timeZone": "Europe/London" }, "created": "2013-04-25T19:56:19.000+0000", "updated": "2013-04-25T19:56:19.000+0000" }, { "id": "249073", "author": { "name": "kosso", "key": "kosso", "displayName": "kosso", "active": true, "timeZone": "Europe/London" }, "body": "OK. I managed to get an SDK built with the fix in place, however, while things appear to be working faster, I can't hear any audio at all now. \r\n\r\nI think it is possibly missing the logic to initialize and then start in this way. Due to the lack of an OnPreparedListener? \r\n\r\n", "updateAuthor": { "name": "kosso", "key": "kosso", "displayName": "kosso", "active": true, "timeZone": "Europe/London" }, "created": "2013-04-25T23:55:28.000+0000", "updated": "2013-04-25T23:55:28.000+0000" }, { "id": "249077", "author": { "name": "rahul002", "key": "rahul002", "displayName": "Rahul Dhingra", "active": true, "timeZone": "America/Los_Angeles" }, "body": "hmmm ... i will look at a module option here .. let me try and implement the fix in a kroll module and then hand over to you for building into the original source? To keep Jira clean, I suggest we take this thread over email / skype at rahul.dhingra@aurusit.com / AurusIT", "updateAuthor": { "name": "rahul002", "key": "rahul002", "displayName": "Rahul Dhingra", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2013-04-26T01:50:59.000+0000", "updated": "2013-04-26T01:50:59.000+0000" }, { "id": "249344", "author": { "name": "sunila", "key": "sunila", "displayName": "Sunila", "active": true, "timeZone": "Asia/Kolkata" }, "body": "Addes async support\r\n\r\nhttps://github.com/appcelerator/titanium_mobile/pull/4220", "updateAuthor": { "name": "sunila", "key": "sunila", "displayName": "Sunila", "active": true, "timeZone": "Asia/Kolkata" }, "created": "2013-04-29T15:10:52.000+0000", "updated": "2013-04-29T15:10:52.000+0000" }, { "id": "249359", "author": { "name": "kosso", "key": "kosso", "displayName": "kosso", "active": true, "timeZone": "Europe/London" }, "body": "Sunila : Thanks for this. It appears to be working a lot better now with prepareAsyc. \r\n\r\nOne thing though, your stop() method seems to still use the non-async prepare() method. \r\n\r\nThanks again.\r\nKosso", "updateAuthor": { "name": "kosso", "key": "kosso", "displayName": "kosso", "active": true, "timeZone": "Europe/London" }, "created": "2013-04-29T16:02:08.000+0000", "updated": "2013-04-29T16:02:08.000+0000" }, { "id": "249524", "author": { "name": "rahul002", "key": "rahul002", "displayName": "Rahul Dhingra", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Sunila,\r\n\r\nWill pull the version and provide feedback..\r\n\r\nRegards,\r\nRahul Dhingra", "updateAuthor": { "name": "rahul002", "key": "rahul002", "displayName": "Rahul Dhingra", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2013-04-30T02:32:47.000+0000", "updated": "2013-04-30T02:32:47.000+0000" }, { "id": "249534", "author": { "name": "rahul002", "key": "rahul002", "displayName": "Rahul Dhingra", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Hi Sunila,\r\n\r\nRequest you to let me know if the fix is available in a continuous build which I can download and rebuild my application accordingly.\r\n\r\nIf not then please let me know how to use the above fix in the app or an article on how to use the same would also be of great help. \r\n\r\nRegards,\r\nRahul Dhingra", "updateAuthor": { "name": "rahul002", "key": "rahul002", "displayName": "Rahul Dhingra", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2013-04-30T06:53:46.000+0000", "updated": "2013-04-30T06:53:46.000+0000" }, { "id": "258287", "author": { "name": "kosso", "key": "kosso", "displayName": "kosso", "active": true, "timeZone": "Europe/London" }, "body": "I managed to get Sunilla's code working for now in a local fork [thanks! :) ] , but I'm looking forward to it working by default. \r\n\r\nAnother bug I should add is that the events don't match between iOS and Android.\r\n\r\nAlso, it would be nice to have an error event on the AudioPlayer for both iOS and Android instead of the native error message which can't be edited (AFAIK). \r\n", "updateAuthor": { "name": "kosso", "key": "kosso", "displayName": "kosso", "active": true, "timeZone": "Europe/London" }, "created": "2013-06-17T22:13:11.000+0000", "updated": "2013-06-17T22:13:11.000+0000" }, { "id": "263971", "author": { "name": "sunila", "key": "sunila", "displayName": "Sunila", "active": true, "timeZone": "Asia/Kolkata" }, "body": "New pull request with changes based on review comments", "updateAuthor": { "name": "sunila", "key": "sunila", "displayName": "Sunila", "active": true, "timeZone": "Asia/Kolkata" }, "created": "2013-07-30T16:52:42.000+0000", "updated": "2013-07-30T16:52:42.000+0000" }, { "id": "265017", "author": { "name": "billdawson", "key": "billdawson", "displayName": "Bill Dawson", "active": true, "timeZone": "Europe/Berlin" }, "body": "h3. Testing Notes\n\n* Use the attached app.js and run the app.\n* Click the button to start -- The stream should play *and* the label at the bottom should indicate that start() returned in less than 1 second.\n* Click the button to stop -- The stream should stop playing *and* the label at the bottom should indicate that stop() returned in less than 1 second.", "updateAuthor": { "name": "billdawson", "key": "billdawson", "displayName": "Bill Dawson", "active": true, "timeZone": "Europe/Berlin" }, "created": "2013-08-05T23:19:52.000+0000", "updated": "2013-08-05T23:19:52.000+0000" }, { "id": "265865", "author": { "name": "sunila", "key": "sunila", "displayName": "Sunila", "active": true, "timeZone": "Asia/Kolkata" }, "body": "Pull request updated with the fix for 'stop'", "updateAuthor": { "name": "sunila", "key": "sunila", "displayName": "Sunila", "active": true, "timeZone": "Asia/Kolkata" }, "created": "2013-08-10T06:21:47.000+0000", "updated": "2013-08-10T06:21:47.000+0000" }, { "id": "267509", "author": { "name": "sunila", "key": "sunila", "displayName": "Sunila", "active": true, "timeZone": "Asia/Kolkata" }, "body": "Added new pull request merging all changes and fixed the issue with async prepare after stop\n\nhttps://github.com/appcelerator/titanium_mobile/pull/4593", "updateAuthor": { "name": "sunila", "key": "sunila", "displayName": "Sunila", "active": true, "timeZone": "Asia/Kolkata" }, "created": "2013-08-21T18:47:06.000+0000", "updated": "2013-08-21T18:47:06.000+0000" }, { "id": "276288", "author": { "name": "lokeshchdhry", "key": "lokeshchdhry", "displayName": "Lokesh Choudhary", "active": false, "timeZone": "America/Los_Angeles" }, "body": "Verified the fix. The start() returns in around 6ms & stop returns around 4ms, which is less than 1sec.\r\nThus closing.\r\n\r\nEnvironment:\r\nAppcel Studio : 3.2.0.201310221639\r\nTi SDK : 3.2.0.v20131022050844\r\nMac OSX : 10.8.5\r\nCLI - 3.2.0 with hash 72f7426b4ee6c2d2883c666d5b7e03906a16012f\r\nDevice: Samsung Galaxy S4 running android 4.2.2", "updateAuthor": { "name": "lokeshchdhry", "key": "lokeshchdhry", "displayName": "Lokesh Choudhary", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2013-10-23T00:50:36.000+0000", "updated": "2013-10-23T00:50:36.000+0000" } ], "maxResults": 22, "total": 22, "startAt": 0 } } }