scrObject Error (Disconnect)

seobi

New Member
Hello.
I'm testing a Canvas Stream with a tip you gave me. Another error occurred during the test. I report it.
In my sample, an error occurs intermittently when disconnecting:

Assigning 'display' to the createStream method as a static 'div' element (localVideo) should not cause any problems. However, assigning a dynamically created 'div' causes problems. I delete the dynamically created div on Flashphoner's Disconnect event. Should I keep it without deleting it?
Note, I was loading and publishing a Full HD video file on Canvas.
Best Regard.

[Sample Code]
if (localvideo == null) {
localvideo = document.createElement('div');​
}
publishStream = session.createStream({
name: streamKey,
display: localvideo,​
}).on(STREAM_STATUS.PUBLISHING, function (stream) {
.....
}


Flashphoner.createSession({urlServer: url}).on(SESSION_STATUS.ESTABLISHED, function (session) {
onConnected(session);​
}).on(SESSION_STATUS.DISCONNECTED, function () {
onDisconnected();​
}).on(SESSION_STATUS.FAILED, function () {
onDisconnected();​
});

onDisconnected() {
localvideo.remove();
localvideo = null;​
}​


[LOG]
==================================================================================
flashphoner.js:35616 09:54:55 INFO webrtc - Initialized
flashphoner.js:35616 09:54:55 INFO websocket - Initialized
flashphoner.js:35616 09:54:55 INFO core - Initialized
FPStream.js:77 connect to flashphoner media server : wss://marioms.rsupport.com:8443
FPStream.js:152 #FP Status : CONNECTED
flashphoner.js:35616 09:54:55 INFO webrtc - {audio: false, video: false, customStream: MediaStream}
flashphoner.js:35616 09:54:55 INFO webrtc - FOUND WEBRTC CACHED INSTANCE, id 0387ca00-1c7a-11ea-9d45-3323c4f2244b-LOCAL_CACHED_VIDEO
flashphoner.js:35682 Searching for codec H264
6flashphoner.js:35686 H264 detected
flashphoner.js:35682 Searching for codec G722
flashphoner.js:35682 Searching for codec ALAW
flashphoner.js:35682 Searching for codec ULAW
FPStream.js:174 #FP Status : PUBLISHING
flashphoner.js:36217 Uncaught (in promise) TypeError: Cannot read property 'srcObject' of null
at flashphoner.js:36217
at flashphoner.js:36211
(anonymous) @ flashphoner.js:36217
(anonymous) @ flashphoner.js:36211
Promise.then (async)
getStat @ flashphoner.js:36209
detectConnectionQuality @ flashphoner.js:11955
streamRefreshHandlers.<computed> @ flashphoner.js:11914
wsConnection.onmessage @ flashphoner.js:10893
FPStream.js:182 #FP Status : UNPUBLISHED
FPStream.js:160 #FP Status : DISCONNECTED
 

Max

Administrator
Staff member
Good day.
We cannot reproduce the problem in Canvas Streaming example. Note that both localVideo and remoteVideo elements are created dinamically in this example:
Code:
function init_page() {
    ...
    //local and remote displays
    localVideo = document.createElement("localVideo");
    remoteVideo = document.getElementById("remoteVideo");
    canvas = document.getElementById("canvas");
    ...
}
We have added localVideo element removing on DISCONNECTED event:
Code:
function onDisconnected() {
    ...
    console.log("Remove local video element");
    localVideo.remove();
    localVideo = null;
}
and its creation before stream publishing
Code:
function startStreaming() {
    if (localVideo == null) {
        console.log("Create local video element");
        localVideo = document.createElement("localVideo");
    }
    var session = Flashphoner.getSessions()[0];
    var streamName = field("urlServer").split('/')[3];
    var constraints = getConstraints();

    session.createStream({
    ...
    }).publish();
}
This code works properly.
Note that excepton in your code is raised while PUBLISHING status handling. So please check your code at this point, or send us minimal code example that reproduces the problem, we will check.
 

seobi

New Member
Hello
It is not reproduced now.
I will test and submit the issue again when it is reproduced.
Thank you for your help.
 

Max

Administrator
Staff member
Good day.
If problem persists, please us minimal code example that reproduces the problem, we will check.
 
Top