Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

WebGL: INVALID_VALUE: texImage2D: no video

Discussion in 'Unity 5 Pre-order Beta' started by jsleek, Dec 10, 2014.

  1. jsleek

    jsleek

    Joined:
    Oct 3, 2014
    Posts:
    61
    I'm running a WebGL build that plays videos and i get this warning error popping up in the console every time.
    It doesnt make a difference for Firefox and Chrome but for Safari the warning message repeats infinitely until it says it can display no more errors. This is what i think is causing my Safari build to run much slower.

    So my questions are:

    1.What does this warning mean?
    2.How can I fix it?
    3.Is it the reason my Safari build is running so slowly compare to the Firefox and Chrome builds?
     
  2. jonas-echterhoff

    jonas-echterhoff

    Unity Technologies

    Joined:
    Aug 18, 2005
    Posts:
    1,666
    how does your build play videos? Got a link?
     
  3. jsleek

    jsleek

    Joined:
    Oct 3, 2014
    Posts:
    61
    Last edited: Dec 11, 2014
  4. jonas-echterhoff

    jonas-echterhoff

    Unity Technologies

    Joined:
    Aug 18, 2005
    Posts:
    1,666
    I'm confused. There is no "built in html5" video functionality in unity webgl?!
     
  5. jsleek

    jsleek

    Joined:
    Oct 3, 2014
    Posts:
    61
    @jonas echterhoff i use a .jslib file with the video tag and use the DLLImport function in my scripts to access the .jslib functions from the unity c# scripts.

    I've attached the .jslib file in this post ( i had to change it to a .txt to upload it here)

    does it make sense now?
     

    Attached Files:

  6. jonas-echterhoff

    jonas-echterhoff

    Unity Technologies

    Joined:
    Aug 18, 2005
    Posts:
    1,666
    Ah, i see, that got me confused. That code looks like it is based on my proof-of-concept html5 video playback code i posted earlier :)

    I'm not quite sure what that error message means, though. Possibly, your video has not been downloaded enough to be playable when you try starting playback?
     
  7. jsleek

    jsleek

    Joined:
    Oct 3, 2014
    Posts:
    61
    @jonas echterhoff It is based off the proof of concept! Thank you for it :)

    That could be true, although surely its not downloading as the video is included in the build? Is there a way for unity to only play the video once it is fully ready to play to ensure the video does not stop half way through? The error message happens with your proof of concept too. Is that the thing responsible for Safari running the build so slowly?

    Also, my WebGL builds are still around 50MB even after omitting all unnecessary details, choosing "fastest" for optimization build, and optimizing mesh data (strip assemblies). Is there any way to reduce the build further? And do i need to put all the files the build produces on the server for it to work? Maybe that's the problem?

    Cheers :)
     
  8. jonas-echterhoff

    jonas-echterhoff

    Unity Technologies

    Joined:
    Aug 18, 2005
    Posts:
    1,666
    Ok, so, yes, it is a matter of video not being fully loaded before we start accessing frames. If you take my sample, it makes sense to add something like this in the beginning of the VideoUpdate function:

    Code (csharp):
    1.  
    2.     if (video.paused)
    3.         return;
    4.  
    That way it won't update the texture if the video is not not playing. It also makes sense to check "video.readyState === video.HAVE_ENOUGH_DATA" before playing to make sure that enough of the video has loaded.

    And, yes, your videos will need to download first. They are not part of the built game data. The JavaScript line video.src = <url>; tells the browser to start downloading the video. The StreamingAssets folder in Unity is a special folder, which makes Assets not imported and included in the build data, but just copied to a folder next to the build (that way the will be there for download). See http://docs.unity3d.com/Manual/StreamingAssets.html .

    As for your build sizes? Are you looking at the "Compressed" folder? If your web server is configured correctly, that is what is ultimately downloaded. Also, see previous discussions on this topic here, and the WebGL section of the Unity 5 manual, which has some more info on build size.
     
  9. Delamore81

    Delamore81

    Joined:
    Oct 24, 2013
    Posts:
    4
    Hi @jonas echterhoff , Is there a link to your post of your proof-of-concept html5 video playback code? Much appreciated.
     
    Last edited: Jan 2, 2015
  10. jonas-echterhoff

    jonas-echterhoff

    Unity Technologies

    Joined:
    Aug 18, 2005
    Posts:
    1,666
  11. Delamore81

    Delamore81

    Joined:
    Oct 24, 2013
    Posts:
    4
  12. Delamore81

    Delamore81

    Joined:
    Oct 24, 2013
    Posts:
    4
    Hi @jonas echterhoff ,

    Good day to you.

    So I tried out your webgl video playback p-o-c, but I came across problems from all the latest versions of the known browsers (IE, Firefox, Chrome, Safari) trying to display the video.

    On top of the same problem as mentioned above - texImage2D: no image - this time, it goes the same for all the browsers. And no video is showing up on the texture of the cube at all. It is either just black, or the cube is totally invisible.

    I have already tried implementing the fixes that you suggested. Though the "returning null if the video is paused" is something you have already implemented.

    Code (JavaScript):
    1. WebGLMovieTextureUpdate: function(video, tex)
    2. {
    3.     if (videoInstances[video].paused)
    4.         return;
    5.     GLctx.bindTexture(GLctx.TEXTURE_2D, GL.textures[tex]);
    6.     GLctx.texImage2D(GLctx.TEXTURE_2D, 0, GLctx.RGBA, GLctx.RGBA, GLctx.UNSIGNED_BYTE, videoInstances[video]);
    7. },
    8.  
    9. WebGLMovieTexturePlay: function(video)
    10. {
    11.     if(video.readyState === video.HAVE_ENOUGH_DATA)
    12.         videoInstances[video].play();
    13. },
    Would you be able to help me with this?

    Thank you very much!

    Screen Shot 01-08-15 at 03.30 PM.PNG
     
  13. jonas-echterhoff

    jonas-echterhoff

    Unity Technologies

    Joined:
    Aug 18, 2005
    Posts:
    1,666
    Looking at your screenshot there, it seems you have a 403 error trying to download something (I guess your video?).
     
  14. Delamore81

    Delamore81

    Joined:
    Oct 24, 2013
    Posts:
    4
    Does this mean the video is not being downloaded at all?
     
  15. jonas-echterhoff

    jonas-echterhoff

    Unity Technologies

    Joined:
    Aug 18, 2005
    Posts:
    1,666
    It looks like it, yes. The URL shown next to the error also looks odd.
     
  16. jsleek

    jsleek

    Joined:
    Oct 3, 2014
    Posts:
    61
    Hi @jonas echterhoff. Im researching the full capabilities of video streaming with Unity WebGL. As we are still on the topic of this, can you tell me to what extent video streaming in Unity WebGL is functional? As in, you provided the proof of concept and it works pretty well, but is there anything not possible right now in terms of video streaming in WebGL?
     
  17. impul101

    impul101

    Joined:
    Feb 8, 2013
    Posts:
    21
    I am having the same issue except I do get audio from the video.
     
    prawn-star likes this.
  18. SevenIslands

    SevenIslands

    Joined:
    May 22, 2013
    Posts:
    9
    Hi I've been trying to implement this but I'm getting the following error:

    PlatformNotSupportedException: WebGLMovieTexture is only supported on WebGL.
    WebGLMovieTexture.WebGLMovieTextureCreate (System.String url) (at Assets/Plugins/WebGLMovieTexture.cs:43)
    WebGLMovieTexture..ctor (System.String url) (at Assets/Plugins/WebGLMovieTexture.cs:92)
    VideoTest.Start () (at Assets/Sample/VideoTest.cs:11)

    What's the problem?
     
  19. jonas-echterhoff

    jonas-echterhoff

    Unity Technologies

    Joined:
    Aug 18, 2005
    Posts:
    1,666
    As it says in the error: "WebGLMovieTexture is only supported on WebGL."

    This code is WebGL specific, and will only work in WebGL builds in the browser.
     
  20. SevenIslands

    SevenIslands

    Joined:
    May 22, 2013
    Posts:
    9
    That's what I'm trying to do. What do I need to do to disable WebGL builds that say build out for iOS or Android?
     
  21. SevenIslands

    SevenIslands

    Joined:
    May 22, 2013
    Posts:
    9
    Ok I figured out the problem. You can't do a test from within Unity. You actually have to build out the webGL application and view it in the browser only. I'm assuming that this won't work on an iOS browser either?
     
  22. smoakes86

    smoakes86

    Joined:
    Jan 15, 2014
    Posts:
    5
    Hi @jonas echterhoff

    Thanks so much for the plugin! Everything is working great apart from the seek. I'm getting an error saying "
    The error was:
    SecurityError: The operation is insecure."

    This only happens with seek though. Any ideas?
     
  23. jonas-echterhoff

    jonas-echterhoff

    Unity Technologies

    Joined:
    Aug 18, 2005
    Posts:
    1,666
    Not really. Does it work with the sample in the plugin folder? It should allow you to seek in the sample by clicking on the scroll bar.
     
  24. smoakes86

    smoakes86

    Joined:
    Jan 15, 2014
    Posts:
    5
    Nope, seek in the sample doesn't work either. When I actually host the game (rather than playing locally in the browser) I get a different error saying that the seek function is calling an external function that doesn't exist.
     
  25. jonas-echterhoff

    jonas-echterhoff

    Unity Technologies

    Joined:
    Aug 18, 2005
    Posts:
    1,666
    88er and ottolb like this.