Bug 239635
Summary: | MediaRecorder causes Network process crashed in about 10 minutes | ||
---|---|---|---|
Product: | WebKit | Reporter: | yuki uchida <rantarn0326> |
Component: | WebRTC | Assignee: | youenn fablet <youennf> |
Status: | RESOLVED FIXED | ||
Severity: | Normal | CC: | cdumez, mark.lam, webkit-bug-importer, youennf |
Priority: | P2 | Keywords: | InRadar |
Version: | Safari 15 | ||
Hardware: | iPhone / iPad | ||
OS: | iOS 15 |
yuki uchida
# Overview
When using WebRTC connection with MediaRecorder, WebSocket Connection crashed in about 10 minutes.
## steps to reproduce
device A: iOS Safari
device B: Google Chrome(Mac)
1. (device A&B) visit https://yuki-uchida.github.io/firebase-webrtc-sample/#roomName
2. (device A&B) Accept permissions for camera and microphone.
3. WebRTC connection and MediaRecording start.
4. Please wait about 10minutes.
## Actual Results
iOS Safari always occurs error.
[Error] WebSocket connection to 'wss://s-usc1a-nss-2015.firebaseio.com/.ws?v=5&ns=~~~~~~' failed: WebSocket network error: Network process crashed.
## Expected Results
No error occurs.
## Hardware
iPhone11 iOS15.4
Attachments | ||
---|---|---|
Add attachment proposed patch, testcase, etc. |
youenn fablet
IS there a way to send me the crash log (youenn@apple.com)?
Ryan Haddad
rdar://92146629
yuki uchida
(In reply to youenn fablet from comment #1)
> IS there a way to send me the crash log (youenn@apple.com)?
Sorry, I don't know how to log in iOS Safari. Is there documentation somewhere?
Also, to add, Safari itself does not crash, although an error occurs and disconnects. Some processes are crashing because of the NetWork Process Crash, I assume!
youenn fablet
Some info might be found here for taking a sysdiagnose: https://developer.apple.com/forums/thread/99634
I will retry today and see what I can get.
One hypothesis is that as you regularly create blobs, the memory usage is growing in network process up to a point where it crashes, which triggers the web socket connection message.
For instance, I can see that there is a download option which triggers creating a big blob from the multiple smaller blobs created by MediaRecorder. Is the crash happening at this time?
youenn fablet
Quickly looking at the provided test in MacOS, I can see the networking process memory usage slowly increasing, probably due to the blobs being kept alive by the web page.
yuki uchida
(In reply to youenn fablet from comment #4)
> Some info might be found here for taking a sysdiagnose:
> https://developer.apple.com/forums/thread/99634
>
> I will retry today and see what I can get.
> One hypothesis is that as you regularly create blobs, the memory usage is
> growing in network process up to a point where it crashes, which triggers
> the web socket connection message.
>
> For instance, I can see that there is a download option which triggers
> creating a big blob from the multiple smaller blobs created by
> MediaRecorder. Is the crash happening at this time?
thank you for reply. I sent crashlogs in email and feedback report(FB10003730).
> For instance, I can see that there is a download option which triggers
> creating a big blob from the multiple smaller blobs created by
> MediaRecorder. Is the crash happening at this time?
`network process crash` is be caused before download().
In additional, I tried to test without timeslice in MediaRecoder.start().
sample code is below.
- without timeslice
- https://yuki-uchida.github.io/firebase-webrtc-sample/
- with timeslice
- https://yuki-uchida.github.io/firebase-webrtc-sample/?timeslice=1000
if MediaRecorder start without tiimeslice, creating blob runs after MediaRecorder stop().
So that, certainly, there is no network process crash, but there is application crash.
In about 30minutes, Safari is frozen and crashed.
I am going to send also this crash logs you.
yuki uchida
(In reply to yuki uchida from comment #6)
> (In reply to youenn fablet from comment #4)
> > Some info might be found here for taking a sysdiagnose:
> > https://developer.apple.com/forums/thread/99634
> >
> > I will retry today and see what I can get.
> > One hypothesis is that as you regularly create blobs, the memory usage is
> > growing in network process up to a point where it crashes, which triggers
> > the web socket connection message.
> >
> > For instance, I can see that there is a download option which triggers
> > creating a big blob from the multiple smaller blobs created by
> > MediaRecorder. Is the crash happening at this time?
>
>
> thank you for reply. I sent crashlogs in email and feedback
> report(FB10003730).
>
> > For instance, I can see that there is a download option which triggers
> > creating a big blob from the multiple smaller blobs created by
> > MediaRecorder. Is the crash happening at this time?
>
> `network process crash` is be caused before download().
>
> In additional, I tried to test without timeslice in MediaRecoder.start().
> sample code is below.
> - without timeslice
> - https://yuki-uchida.github.io/firebase-webrtc-sample/
> - with timeslice
> - https://yuki-uchida.github.io/firebase-webrtc-sample/?timeslice=1000
>
> if MediaRecorder start without tiimeslice, creating blob runs after
> MediaRecorder stop().
> So that, certainly, there is no network process crash, but there is
> application crash.
> In about 30minutes, Safari is frozen and crashed.
>
> I am going to send also this crash logs you.
I would add.
If you want to record only your own stream, use `?useRemoteRecorder=false`; if you want to record the other party's stream as well, use `?useRemoteRecorder=true` as a parameter to the URL.
The URL that confirmed the Safari application crash is strictly the following URL.
- https://yuki-uchida.github.io/firebase-webrtc-sample/?useRemoteRecorder=true
We have not confirmed the case of `useRemoteRecorder=false`, but it will probably take longer to crash.
Translated with www.DeepL.com/Translator (free version)
youenn fablet
Looking at the crash log, I can see the device is on memory pressure just before networking process crashes:
2022-05-02 10:40:01.784768+0900 0x4F050E Default 0x0 10384 com.apple.WebKit.Networking: (JavaScriptCore) [com.apple.WebKit:MemoryPressure] Memory pressure relief: Total: res = 28508160/28508160/0, res+swap = 880560104/880560104/0
2022-05-02 10:40:01.784769+0900 0x4F050E Default 0x0 10384 com.apple.WebKit.Networking: (JavaScriptCore) [com.apple.WebKit:MemoryPressure] Received memory pressure event 32 vm pressure 1
My understanding is that the networking process has a lot of blobs.
To trigger the download, the web app creates a new blob concatenating all blobs into one blob. This double the memory size used for blobs.
This probably triggers the crash.
While we can try to optimise the case of handling a lot of large blobs internally, I can see some workarounds:
- Use https://fs.spec.whatwg.org/ to store the data on disk instead of in memory. When triggering download, use the corresponding File object.
- Use service worker to feed blob data progressively as the download through ReadableStream.
First option is probably the preferred option.
youenn fablet
@uchida-san, I am closing this radar, given the behavior is somehow expected.
Could you try using one of the workaround and see whether that fixes your issue?
If not, please reopen this bug entry.
yuki uchida
(In reply to youenn fablet from comment #9)
> @ uchidaさん、どういうわけか予想される振る舞いを考えて、このレーダーを閉じます。
> 回避策の1つを使用してみて、それで問題が解決するかどうかを確認できますか?
> そうでない場合は、このバグエントリを再度開いてください。
Thank you for the solution.
However, I made some modifications to the verification application and investigated again, and found that the `network process crashed` was occurring every 10 minutes or so, even before the blob binding was done.
We started recording by specifying timeslice as recorder.start(1000), and the data that became ondataavailable was not stored anywhere as is
````
this.mediaRecorder.ondataavailable = (event) => {
if (event.data && event.data.size > 0) {
console.log(event);
// this.blobs.push(event.data);
// this.blob = event.data;
}
}
```
But in fact I get `network process crashed` - is garbage collection not working?
youenn fablet
(In reply to yuki uchida from comment #10)
> (In reply to youenn fablet from comment #9)
> > @ uchidaさん、どういうわけか予想される振る舞いを考えて、このレーダーを閉じます。
> > 回避策の1つを使用してみて、それで問題が解決するかどうかを確認できますか?
> > そうでない場合は、このバグエントリを再度開いてください。
>
>
> Thank you for the solution.
>
> However, I made some modifications to the verification application and
> investigated again, and found that the `network process crashed` was
> occurring every 10 minutes or so, even before the blob binding was done.
>
> We started recording by specifying timeslice as recorder.start(1000), and
> the data that became ondataavailable was not stored anywhere as is
>
> ````
> this.mediaRecorder.ondataavailable = (event) => {
> if (event.data && event.data.size > 0) {
> console.log(event);
> // this.blobs.push(event.data);
> // this.blob = event.data;
> }
> }
> ```
>
> But in fact I get `network process crashed` - is garbage collection not
> working?
Good point about GC, I am not sure that we actually rel.
We might be missing that blobs are big chunk of data which data is owned by a given page.
youenn fablet
Pull request: https://github.com/WebKit/WebKit/pull/3448
EWS
Committed 253767@main (c8d357e13dfb): <https://commits.webkit.org/253767@main>
Reviewed commits have been landed. Closing PR #3448 and removing active labels.