Bug 174407

Summary: H264VideoToolboxDecoder::Decode has a memory leak when homing out on iOS
Product: WebKit Reporter: youenn fablet <youennf>
Component: MediaAssignee: youenn fablet <youennf>
Status: RESOLVED CONFIGURATION CHANGED    
Severity: Normal CC: achristensen, buildbot, eric.carlson, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
none
Archive of layout-test-results from ews123 for ios-simulator-wk2
none
Patch achristensen: review-

youenn fablet
Reported 2017-07-11 17:29:59 PDT
H264VideoToolboxDecoder::Decode has a memory leak when homing out on iOS
Attachments
Patch (2.32 KB, patch)
2017-07-11 17:33 PDT, youenn fablet
no flags
Archive of layout-test-results from ews123 for ios-simulator-wk2 (1.07 MB, application/zip)
2017-07-12 00:31 PDT, Build Bot
no flags
Patch (2.70 KB, patch)
2017-07-12 17:04 PDT, youenn fablet
achristensen: review-
youenn fablet
Comment 1 2017-07-11 17:30:16 PDT
youenn fablet
Comment 2 2017-07-11 17:33:03 PDT
Build Bot
Comment 3 2017-07-11 18:34:10 PDT
Attachment 315197 [details] did not pass style-queue: ERROR: Source/ThirdParty/libwebrtc/Source/webrtc/sdk/objc/Framework/Classes/VideoToolbox/decoder.mm:146: Weird number of spaces at line-start. Are you using a 4-space indent? [whitespace/indent] [3] ERROR: Source/ThirdParty/libwebrtc/Source/webrtc/sdk/objc/Framework/Classes/VideoToolbox/decoder.mm:160: Weird number of spaces at line-start. Are you using a 4-space indent? [whitespace/indent] [3] Total errors found: 2 in 2 files If any of these errors are false positives, please file a bug against check-webkit-style.
Alex Christensen
Comment 4 2017-07-12 00:02:51 PDT
Comment on attachment 315197 [details] Patch Does VTDecompressionSessionDecodeFrame delete the pointer when it's done? I think this whole function's memory management needs to be made much more clear. I think the first new should be replaced with std::make_unique. Do we need to manually delete the released unique_ptr if both calls fail?
Build Bot
Comment 5 2017-07-12 00:31:09 PDT
Comment on attachment 315197 [details] Patch Attachment 315197 [details] did not pass ios-sim-ews (ios-simulator-wk2): Output: http://webkit-queues.webkit.org/results/4105460 New failing tests: webrtc/captureCanvas-webrtc.html
Build Bot
Comment 6 2017-07-12 00:31:10 PDT
Created attachment 315213 [details] Archive of layout-test-results from ews123 for ios-simulator-wk2 The attached test failures were seen while running run-webkit-tests on the ios-sim-ews. Bot: ews123 Port: ios-simulator-wk2 Platform: Mac OS X 10.12.5
youenn fablet
Comment 7 2017-07-12 12:56:25 PDT
> Does VTDecompressionSessionDecodeFrame delete the pointer when it's done? I > think this whole function's memory management needs to be made much more > clear. I think the first new should be replaced with std::make_unique. Do > we need to manually delete the released unique_ptr if both calls fail? VTDecompressionSessionDecodeFrame is just getting a pointer and passing it to the callback that retakes it as a unique_ptr. As long as VTDecompressionSessionDecodeFrame does not call the callback when returning an error result, this patch is fine. I'll change the patch to use make_unique instead of the current code.
youenn fablet
Comment 8 2017-07-12 12:57:55 PDT
(In reply to Build Bot from comment #5) > Comment on attachment 315197 [details] > Patch > > Attachment 315197 [details] did not pass ios-sim-ews (ios-simulator-wk2): > Output: http://webkit-queues.webkit.org/results/4105460 > > New failing tests: > webrtc/captureCanvas-webrtc.html Hum, this test is crashing probably because of my patch, I'll check that further.
youenn fablet
Comment 9 2017-07-12 17:04:21 PDT
youenn fablet
Comment 10 2017-07-12 17:05:49 PDT
> As long as VTDecompressionSessionDecodeFrame does not call the callback when > returning an error result, this patch is fine. This assumption does not hold, I have changed the patch to just remove the unnecessary double allocation. This should fix the leak in the case I spotted. This does not fix all potential cases I guess. A future patch should do proper handling there.
Build Bot
Comment 11 2017-07-12 17:06:45 PDT
Attachment 315310 [details] did not pass style-queue: ERROR: Source/ThirdParty/libwebrtc/Source/webrtc/sdk/objc/Framework/Classes/VideoToolbox/decoder.mm:141: Weird number of spaces at line-start. Are you using a 4-space indent? [whitespace/indent] [3] ERROR: Source/ThirdParty/libwebrtc/Source/webrtc/sdk/objc/Framework/Classes/VideoToolbox/decoder.mm:144: Weird number of spaces at line-start. Are you using a 4-space indent? [whitespace/indent] [3] ERROR: Source/ThirdParty/libwebrtc/Source/webrtc/sdk/objc/Framework/Classes/VideoToolbox/decoder.mm:156: Weird number of spaces at line-start. Are you using a 4-space indent? [whitespace/indent] [3] ERROR: Source/ThirdParty/libwebrtc/Source/webrtc/sdk/objc/Framework/Classes/VideoToolbox/decoder.mm:157: Weird number of spaces at line-start. Are you using a 4-space indent? [whitespace/indent] [3] Total errors found: 4 in 2 files If any of these errors are false positives, please file a bug against check-webkit-style.
Alex Christensen
Comment 12 2017-07-12 17:13:54 PDT
Comment on attachment 315310 [details] Patch Both callbacks are responsible for deleting the FrameDecodeParams* with this design. This is *very* bad. We need to refcount instead if we give two callbacks ownership of the object.
Note You need to log in before you can comment on or make changes to this bug.