arabenseifer / google-cast-sdk

Automatically exported from code.google.com/p/google-cast-sdk
0 stars 0 forks source link

GCKMediaInformation streamDuration = NSInterval.infinity throw NSInvalid Argument for JSON infinity value #475

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
// Trying to send MP4 stream with moof packets, my context but not related to 
issue.
var mediaInformation: GCKMediaInformation(
_,
streamType: GCKMediaStreamType.Live, // <- Valid parameter with streamDuration 
as infinity.
_,
streamDuration: NSTimeInterval.infinity, // <- This ultimately causes the issue.
_)

var mediaControlChannel:
mediaControlChannel.loadMedia(
mediaInformation,
_) // <- loadMedia tries to flatten streamDuration when set to infinity as JSON 
data. Causes exception.

What is the expected output? What do you see instead?
Expect success / No exception
Actual NSInvalidArgument Exception for JSON parse on infinity value.

What version of the product are you using? On what operating system?
Googlecast SDK 2.5.1
Yosemite OSX / Xcode simulator / iOS 8.1.2

Please provide any additional information below.
The document below (specifically states the above parameters) are correct:
https://developers.google.com/cast/docs/reference/ios/interface_g_c_k_media_info
rmation#aaa26b93beb30eccccf3430a52eebe6c9

Original issue reported on code.google.com by samson1...@gmail.com on 6 Jan 2015 at 2:22

GoogleCodeExporter commented 9 years ago
The SDK docs indicate that you should use INFINITY (from math.h), which is a 
valid (but very large) double value. I suspect that Swift's 
NSTimeInterval.infinity is some other, special value that is not a valid value 
for a double.

Original comment by mlind...@google.com on 6 Jan 2015 at 8:19

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Thank you for responding so soon. I have just tried to use the INFINITY from 
<math.h> and got the same error. (Below is the call stack). FYI NSTimeInterval 
is a alias for double. So NSTimeInterval.infinity is positive infinity. Unless 
I am mistaken it wouldn't make sense to me that there are multiple "values" for 
"infinity" for a double.

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', 
reason: 'Invalid number value (infinite) in JSON write'
*** First throw call stack:
(
    0   CoreFoundation                      0x030cb946 __exceptionPreprocess + 182
    1   libobjc.A.dylib                     0x02693a97 objc_exception_throw + 44
    2   CoreFoundation                      0x030cb86d +[NSException raise:format:] + 141
    3   Foundation                          0x00aa232e _writeJSONNumber + 962
    4   Foundation                          0x00a9e14e _writeJSONValue + 561
    5   Foundation                          0x00aa2bf2 ___writeJSONObject_block_invoke + 225
    6   CoreFoundation                      0x02ffc15a __65-[__NSDictionaryM enumerateKeysAndObjectsWithOptions:usingBlock:]_block_invoke + 106
    7   CoreFoundation                      0x02ffc05c -[__NSDictionaryM enumerateKeysAndObjectsWithOptions:usingBlock:] + 204
    8   CoreFoundation                      0x02ff36e5 -[NSDictionary enumerateKeysAndObjectsUsingBlock:] + 53
    9   Foundation                          0x00aa27a1 _writeJSONObject + 357
    10  Foundation                          0x00a9e143 _writeJSONValue + 550
    11  Foundation                          0x00aa2bf2 ___writeJSONObject_block_invoke + 225
    12  CoreFoundation                      0x02ffc15a __65-[__NSDictionaryM enumerateKeysAndObjectsWithOptions:usingBlock:]_block_invoke + 106
    13  CoreFoundation                      0x02ffc05c -[__NSDictionaryM enumerateKeysAndObjectsWithOptions:usingBlock:] + 204
    14  CoreFoundation                      0x02ff36e5 -[NSDictionary enumerateKeysAndObjectsUsingBlock:] + 53
    15  Foundation                          0x00aa27a1 _writeJSONObject + 357
    16  Foundation                          0x00a9e143 _writeJSONValue + 550
    17  Foundation                          0x00a9dedd -[_NSJSONWriter dataWithRootObject:options:error:] + 125
    18  Foundation                          0x00aa0e44 +[NSJSONSerialization dataWithJSONObject:options:error:] + 371

*fixed spelling mistakes*

Original comment by samson1...@gmail.com on 7 Jan 2015 at 12:45

GoogleCodeExporter commented 9 years ago
It would be probably helpful if I gave you the next three items in the stack as 
well...

19  _AppName_                     0x0026744c +[GCKJSONUtils writeJSON:] + 68
20  _AppName_                     0x00269398 -[GCKMediaControlChannel 
loadMedia:autoplay:playPosition:activeTrackIDs:customData:] + 1151
21  _AppName_                     0x00268e3d -[GCKMediaControlChannel 
loadMedia:autoplay:playPosition:] + 76

Original comment by samson1...@gmail.com on 7 Jan 2015 at 12:52

GoogleCodeExporter commented 9 years ago
I wanted to ensure it wasn't my code generating this error. So I modified the 
Obj-C iOS HelloVideoGoogleCast demo source provided by Google, with the 
following at Line 202 on HGCVViewController.m. It generated the same error. 
(Captured below) 

    GCKMediaInformation *mediaInformation =
    [[GCKMediaInformation alloc] initWithContentID:
     @"http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4"
                                        streamType:GCKMediaStreamTypeLive
                                       contentType:@"video/mp4"
                                          metadata:metadata
                                    streamDuration:INFINITY
                                        customData:nil];

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', 
reason: 'Invalid number value (infinite) in JSON write'
*** First throw call stack:
(
    0   CoreFoundation                      0x0201f946 __exceptionPreprocess + 182
    1   libobjc.A.dylib                     0x01ca8a97 objc_exception_throw + 44
    2   CoreFoundation                      0x0201f86d +[NSException raise:format:] + 141
    3   Foundation                          0x019b932e _writeJSONNumber + 962
    4   Foundation                          0x019b514e _writeJSONValue + 561
    5   Foundation                          0x019b9bf2 ___writeJSONObject_block_invoke + 225
    6   CoreFoundation                      0x01f5015a __65-[__NSDictionaryM enumerateKeysAndObjectsWithOptions:usingBlock:]_block_invoke + 106
    7   CoreFoundation                      0x01f5005c -[__NSDictionaryM enumerateKeysAndObjectsWithOptions:usingBlock:] + 204
    8   CoreFoundation                      0x01f476e5 -[NSDictionary enumerateKeysAndObjectsUsingBlock:] + 53
    9   Foundation                          0x019b97a1 _writeJSONObject + 357
    10  Foundation                          0x019b5143 _writeJSONValue + 550
    11  Foundation                          0x019b9bf2 ___writeJSONObject_block_invoke + 225
    12  CoreFoundation                      0x01f5015a __65-[__NSDictionaryM enumerateKeysAndObjectsWithOptions:usingBlock:]_block_invoke + 106
    13  CoreFoundation                      0x01f5005c -[__NSDictionaryM enumerateKeysAndObjectsWithOptions:usingBlock:] + 204
    14  CoreFoundation                      0x01f476e5 -[NSDictionary enumerateKeysAndObjectsUsingBlock:] + 53
    15  Foundation                          0x019b97a1 _writeJSONObject + 357
    16  Foundation                          0x019b5143 _writeJSONValue + 550
    17  Foundation                          0x019b4edd -[_NSJSONWriter dataWithRootObject:options:error:] + 125
    18  Foundation                          0x019b7e44 +[NSJSONSerialization dataWithJSONObject:options:error:] + 371
    19  HelloVideoGoogleCast                0x0008fefc +[GCKJSONUtils writeJSON:] + 68
    20  HelloVideoGoogleCast                0x00091e48 -[GCKMediaControlChannel loadMedia:autoplay:playPosition:activeTrackIDs:customData:] + 1151
    21  HelloVideoGoogleCast                0x000918ed -[GCKMediaControlChannel loadMedia:autoplay:playPosition:] + 76
    22  HelloVideoGoogleCast                0x000742de -[HGCVViewController castVideo:] + 1566
    23  libobjc.A.dylib                     0x01cbe7cd -[NSObject performSelector:withObject:withObject:] + 84
    24  UIKit                               0x0068123d -[UIApplication sendAction:to:from:forEvent:] + 99
    25  UIKit                               0x006811cf -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 64
    26  UIKit                               0x007b4e86 -[UIControl sendAction:to:forEvent:] + 69
    27  UIKit                               0x007b52a3 -[UIControl _sendActionsForEvents:withEvent:] + 598
    28  UIKit                               0x007b450d -[UIControl touchesEnded:withEvent:] + 660
    29  UIKit                               0x006d160a -[UIWindow _sendTouchesForEvent:] + 874
    30  UIKit                               0x006d20e5 -[UIWindow sendEvent:] + 791
    31  UIKit                               0x00697549 -[UIApplication sendEvent:] + 242
    32  UIKit                               0x006a737e _UIApplicationHandleEventFromQueueEvent + 20690
    33  UIKit                               0x0067bb19 _UIApplicationHandleEventQueue + 2206
    34  CoreFoundation                      0x01f431df __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
    35  CoreFoundation                      0x01f38ced __CFRunLoopDoSources0 + 253
    36  CoreFoundation                      0x01f38248 __CFRunLoopRun + 952
    37  CoreFoundation                      0x01f37bcb CFRunLoopRunSpecific + 443
    38  CoreFoundation                      0x01f379fb CFRunLoopRunInMode + 123
    39  GraphicsServices                    0x02c9324f GSEventRunModal + 192
    40  GraphicsServices                    0x02c9308c GSEventRun + 104
    41  UIKit                               0x0067f8b6 UIApplicationMain + 1526
    42  HelloVideoGoogleCast                0x00075a7d main + 141
    43  libdyld.dylib                       0x02940ac9 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException

Original comment by samson1...@gmail.com on 7 Jan 2015 at 2:12

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Thank you for all the info. We are looking into the issue. 

Original comment by na...@google.com on 7 Jan 2015 at 11:22

GoogleCodeExporter commented 9 years ago
This has been fixed for the next SDK release.

Original comment by mlind...@google.com on 10 Jan 2015 at 2:35

GoogleCodeExporter commented 9 years ago

Original comment by na...@google.com on 12 Jan 2015 at 6:20