Search Unity

Is there any demo for LoadFromStream with correct custom stream?

Discussion in 'Asset Bundles' started by watsonsong, Apr 17, 2018.

  1. watsonsong

    watsonsong

    Joined:
    May 13, 2015
    Posts:
    555
    I try to implement my own custom stream used for LoadFromStream but the editor is always crash:
    https://fogbugz.unity3d.com/default.asp?1027037_mgidnt7681no0obt
    https://fogbugz.unity3d.com/default.asp?1026629_5fcls69ahuh3o05a

    I don't know where is the error, or something wrong with my code.I read carefully about the restrictions of the stream in the document:
    https://docs.unity3d.com/ScriptReference/AssetBundle.LoadFromStream.html

    But I still can not find out why my stream failed and make crash. I seach the github but can not find any demo code for implement a custom stream used for LoadFromStream.

    Is there anyone can give my some tips?
     
  2. watsonsong

    watsonsong

    Joined:
    May 13, 2015
    Posts:
    555
    I remove all my logic but just a bare redirect custom stream, it still make the unity editor crash:

    Code (CSharp):
    1. Mono DLL loaded successfully at 'C:\Program Files\Unity 2018.1.0b13\Editor\Data\MonoBleedingEdge\EmbedRuntime\mono-2.0-bdwgc.dll'.
    2.  
    3.  
    4. Stack Trace of Crashed Thread 12636:
    5. 0x000007FEDEDC31A1 (mono-2.0-bdwgc) [c:\buildslave\mono\build\mono\metadata\metadata.c:5256] mono_metadata_class_equal
    6. 0x000007FEDEDC02F4 (mono-2.0-bdwgc) [c:\buildslave\mono\build\mono\metadata\metadata.c:5091] _mono_metadata_generic_class_equal
    7. 0x000007FEDEDE6F1A (mono-2.0-bdwgc) [c:\buildslave\mono\build\mono\metadata\mono-hash.c:119] mono_g_hash_table_find_slot
    8. 0x000007FEDEDE7455 (mono-2.0-bdwgc) [c:\buildslave\mono\build\mono\metadata\mono-hash.c:266] mono_g_hash_table_lookup
    9. 0x000007FEDEE45D59 (mono-2.0-bdwgc) [c:\buildslave\mono\build\mono\metadata\reflection.c:476] mono_type_get_object_checked
    10. 0x000007FEDEDF1ED9 (mono-2.0-bdwgc) [c:\buildslave\mono\build\mono\metadata\object.c:2135] mono_class_create_runtime_vtable
    11. 0x000007FEDEDF304D (mono-2.0-bdwgc) [c:\buildslave\mono\build\mono\metadata\object.c:1830] mono_class_vtable_full
    12. 0x000007FEDEDF20A0 (mono-2.0-bdwgc) [c:\buildslave\mono\build\mono\metadata\object.c:2218] mono_class_create_runtime_vtable
    13. 0x000007FEDEDF304D (mono-2.0-bdwgc) [c:\buildslave\mono\build\mono\metadata\object.c:1830] mono_class_vtable_full
    14. 0x000007FEDEDF2F83 (mono-2.0-bdwgc) [c:\buildslave\mono\build\mono\metadata\object.c:1797] mono_class_vtable
    15. 0x000007FEDEED3386 (mono-2.0-bdwgc) [c:\buildslave\mono\build\mono\mini\method-to-ir.c:9986] mono_method_to_ir
    16. 0x000007FEDEE77A69 (mono-2.0-bdwgc) [c:\buildslave\mono\build\mono\mini\mini.c:3441] mini_method_compile
    17. 0x000007FEDEE7DA21 (mono-2.0-bdwgc) [c:\buildslave\mono\build\mono\mini\mini.c:4177] mono_jit_compile_method_inner
    18. 0x000007FEDEE82EC2 (mono-2.0-bdwgc) [c:\buildslave\mono\build\mono\mini\mini-runtime.c:2133] mono_jit_compile_method_with_opt
    19. 0x000007FEDEF934E6 (mono-2.0-bdwgc) [c:\buildslave\mono\build\mono\mini\mini-trampolines.c:716] common_call_trampoline
    20. 0x000007FEDEF95E04 (mono-2.0-bdwgc) [c:\buildslave\mono\build\mono\mini\mini-trampolines.c:848] mono_magic_trampoline
    21. 0x000000000E3303A3 (Mono JIT Code) <unknown class>.<unknown method>()
    From the log I found the carsh come from 'mono_metadata_class_equal'. And something the editor will not crash but all script reference is missing in the prefab loaded. So I think the metadata_class must be some error?

    And I test do not use any custom stream but the file stream directly, it crash again:
    Code (CSharp):
    1. var file = File.OpenRead(path);
    2. //var stream = new CryptStream(file, this.Keyt);
    3. return AssetBundle.LoadFromStreamAsync(
    4.     /*stream*/file, 0, this.ReadBufferSize);
    BTW, Not all asset bundle failed, but when my game load some asset bundle when I click the first dialog and show the next UI prefab. I am using the .Net 4.x and .Net Standard 2.0. I don't known whether it is the issue.
     
    Last edited: Apr 17, 2018
  3. watsonsong

    watsonsong

    Joined:
    May 13, 2015
    Posts:
    555
    This problem is still existed in unity2018.2b10, is there any one met the same problem?
     
  4. tylo

    tylo

    Joined:
    Dec 7, 2009
    Posts:
    154
    I've run into a similar problem, but only when I attempt to start 8-10 coroutines that are each attempting to open a separate asset bundle using LoadFromStream or LoadFromStreamAsync.

    I created a bug report, but have not heard back from Unity yet.

    It's happening in 2018.3 for me.

    I know this API call was introduced in 2017, so I am guessing not many people use it. But, I work with a team that desperately would like to use it, and it does appear to work faster/smoother than LoadFromMemory when it doesn't crash. But, since we can only load about 8 AssetBundles at a time without crashing, it's not an option for us until its fixed.

    For any Unity employees reading this, my case number is Case 1135251
     
    Last edited: Mar 14, 2019
  5. watsonsong

    watsonsong

    Joined:
    May 13, 2015
    Posts:
    555
    Hi, @tylo
    How about this problem. Is it fixed in newer version?
     
  6. tylo

    tylo

    Joined:
    Dec 7, 2009
    Posts:
    154
    It is not, yet. They did see the bug, were able to duplicate it, and told me they would tell me when it was. I suppose it's not a high priority since LoadFromMemory works, it just needs to be set up differently.

    Last update heard form them was on March 26th