Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-26533] iOS: Ti.Media.Audio player without url set is crashing while registering for event listener

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2018-11-13T10:52:41.000+0000
Affected Version/sRelease 7.5.0
Fix Version/sRelease 7.5.0
ComponentsiOS
Labelsregression
ReporterSamir Mohammed
AssigneeVijay Singh
Created2018-11-08T15:16:19.000+0000
Updated2018-11-14T10:26:54.000+0000

Description

The application throws an error when using the following test case:
var win = Ti.UI.createWindow({
    backgroundColor: '#fff'
});

	var debug = Ti.API.debug;
	var info = Ti.API.info;
	Ti.Media.audioSessionMode = Ti.Media.AUDIO_SESSION_MODE_PLAYBACK;

	var url = Titanium.UI.createTextField({
		value : 'http://users.skynet.be/fa046054/home/P22/track06.mp3',
		color : '#336699',
		returnKeyType : Titanium.UI.RETURNKEY_GO,
		keyboardType : Titanium.UI.KEYBOARD_URL,
		hintText : 'url',
		textAlign : 'left',
		height : 35,
		top : 10,
		width : 300,
		borderStyle : Titanium.UI.INPUT_BORDERSTYLE_ROUNDED
	});

	var streamButton = Titanium.UI.createButton({
		title : 'Start Streaming',
		top : 60,
		width : 200,
		height : 40
	});

	var pauseButton = Titanium.UI.createButton({
		title : 'Pause Streaming',
		top : 110,
		width : 200,
		height : 40,
		enabled : false
	});

	var progressLabel = Titanium.UI.createLabel({
		text : 'Time Played: Not Started',
		top : 160,
		left : 10,
		height : 40,
		width : 300,
		color : '#555',
		textAlignment : 'center'
	});

	var stateLabel = Titanium.UI.createLabel({
		text : 'State: Not Started',
		top : 180,
		left : 10,
		width : 300,
		height : 40,
		color : '#555'
	});

	win.add(url);
	win.add(streamButton);
	win.add(pauseButton);
	win.add(progressLabel);
	win.add(stateLabel);

	var streamer = Ti.Media.createAudioPlayer();

	streamButton.addEventListener('click', function() {
		if (streamButton.title == 'Stop Stream') {
			progressLabel.text = 'Stopped';
			streamer.stop();
			pauseButton.enabled = false;
			pauseButton.title = 'Pause Streaming';
			streamButton.title = "Start Streaming";
		} else {
			progressLabel.text = 'Starting ...';
			streamer.url = url.value;
			streamer.start();
			pauseButton.enabled = true;
			pauseButton.title = 'Pause Streaming';
			streamButton.title = "Stop Stream";
		}
	});

	pauseButton.addEventListener('click', function() {
		if (pauseButton.title == 'Pause Streaming') {
			streamer.pause();
			pauseButton.title = 'Unpause Streaming';
		} else {
			streamer.start();
			pauseButton.title = 'Pause Streaming';
		}
	});

	streamer.addEventListener('change', function(e) {
		stateLabel.text = 'State: ' + e.description + ' (' + e.state + ')';
		Ti.API.info('disc: ' + e.description);
		Ti.API.info('state: ' + e.state);
	});

	streamer.addEventListener('progress', function(e) {
		progressLabel.text = 'Time Played: ' + Math.round(e.progress) + ' seconds';
	});

	// save off current idle timer state
	var idleTimer = Ti.App.idleTimerDisabled;

	// while we're in this window don't let the app shutdown
	// when the screen is idle
	Ti.App.idleTimerDisabled = true;

	win.addEventListener('close', function() {
		Ti.API.info("window was closed, idleTimer reset to = " + idleTimer);

		// restore previous idle state when closed
		Ti.App.idleTimerDisabled = idleTimer;
	});

	win.open();
Following error is shown:
[ERROR] :  Script Error {
[ERROR] :      column = 26;
[ERROR] :      line = 97;
[ERROR] :      message = "Invalid URL passed to the audio-player";
[ERROR] :      nativeLocation = "-[TiMediaAudioPlayerProxy player] (TiMediaAudioPlayerProxy.m:76)";
[ERROR] :      nativeReason = "The \"url\" probably has not been set to a valid value.";
[ERROR] :      nativeStack = "3   T3    0x00000001011081e8 T3 + 508392\n4   T3    0x000000010110c000 T3 + 524288\n5   T3    0x000000010110b988 T3 + 522632\n6   T3    0x0000000101106b78 T3 + 502648\n7   CoreFoundation  0x0000000185a35630 <redacted> + 144\n8   CoreFoundation  0x0000000185913560 <redacted> + 292\n9   T3    0x00000001010ad8e8 T3 + 137448\n10  T3    0x00000001010abfcc T3 + 131020\n11  T3    0x0000000101128c1c T3 + 642076\n12  T3    0x00000001010abcec T3 + 130284\n13  JavaScriptCore  0x000000018d656b58 <redacted> + 348\n14  JavaScriptCore  0x000000018dd40f5c <redacted> + 352\n15  JavaScriptCore  0x000000018d62ddd8 <redacted> + 29992\n16  JavaScriptCore  0x000000018d62ddec <redacted> + 30012\n17  JavaScriptCore  0x000000018d6266b4 <redacted> + 308\n18  JavaScriptCore  0x000000018dc9cda0 <redacted> + 9620\n19  JavaScriptCore  0x000000018de77ecc _ZN3JSC8evaluateEPNS_9ExecStateERKNS_10SourceCodeENS_7JSValueERN3WTF8NakedPtrINS_9ExceptionEEE + 320";
[ERROR] :      sourceURL = "file:///var/containers/Bundle/Application/977A5AE0-84DB-4956-B8B5-79A219E25A27/T3.app/app.js";
[ERROR] :      stack = "    at [native code]\n    at (/app.js:97:26)\n    at global code(/app.js:116:70)\n    at require@[native code]\n    at (/ti.main.js:27:8)\n    at loadAsync(/ti.internal/bootstrap.loader.js:148:186)\n    at global code(/ti.main.js:24:52)";
[ERROR] :      toJSON = "<KrollCallback: 0x281918ac0>";
[ERROR] :  }
[ERROR] :  Script Error Module "app.js" failed to leave a valid exports object
Note this worked on 7.4.1.GA and looks like a regression. *Expected result* Application should not crash and stream should work accordingly. (If stream is paused/played) *Actual result * Application crashes on launch

Comments

  1. Vijay Singh 2018-11-12

    This issue is regression due to TIMOB-24909. A workaround for this is set url at creation time of audio player.
  2. Vijay Singh 2018-11-12

    PR (master) - https://github.com/appcelerator/titanium_mobile/pull/10457 PR (7_5_X) - https://github.com/appcelerator/titanium_mobile/pull/10456
  3. Samir Mohammed 2018-11-12

    FR Passed waiting on CR and Jenkins builds.
  4. Jan Vennemann 2018-11-13

    CR passed!
  5. Samir Mohammed 2018-11-14

    *Closing ticket.* Fix verified in SDK version 7.5.0.v20181113143835 and SDK version 8.0.0.v20181113150129. *Test and other information can be found at: * PR (master) - https://github.com/appcelerator/titanium_mobile/pull/10457 PR (7_5_X) - https://github.com/appcelerator/titanium_mobile/pull/10456

JSON Source