Herbert Posted October 3, 2017 Share Posted October 3, 2017 hi, The error message does not print on console page if it is triggered right after an asset is loaded, has anyone met the same issue?https://www.babylonjs-playground.com/#11BH6Z#312 If I give it a little delay then it shows normally. This also happens when I use assetsManager.addMeshTask. Quote Link to comment Share on other sites More sharing options...
Sebavan Posted October 3, 2017 Share Posted October 3, 2017 Thanks for reporting I added the issue as a github one here: https://github.com/BabylonJS/Babylon.js/issues/2889 I mark this as solved as it is now tracked on the repo. Herbert 1 Quote Link to comment Share on other sites More sharing options...
Herbert Posted October 3, 2017 Author Share Posted October 3, 2017 thanks @Sebavan, but seems it does not only happen to playground, perhaps the title should change? Quote Link to comment Share on other sites More sharing options...
Sebavan Posted October 3, 2017 Share Posted October 3, 2017 Actually this is normal outside as you would need to you the errorCallback: https://www.babylonjs-playground.com/#11BH6Z#315 Quote Link to comment Share on other sites More sharing options...
Herbert Posted October 3, 2017 Author Share Posted October 3, 2017 Sorry I don't quite get it, my understanding for errorCallback is that it will be called when the asset is failed to be loaded, but in this case the asset is loaded successfully, just something goes wrong in my onsuccess callback. Actually the one I use is assetsManager.onFinish, it has the same issue. I will temporary remove the solved tag since I am still a bit confused. Quote Link to comment Share on other sites More sharing options...
Sebavan Posted October 3, 2017 Share Posted October 3, 2017 Actually, the error in the load callback is triggering the error callback explaining the behavior you have. I agree now it is a bit strange but we could consider the callback as part of the loading process where you might rearrange your meshes and so on. I am a bit wondering if we should change this behavior knowing some user are probably already relying on it in their app and this would be a breaking change. Summoning @Deltakosh for pragmatism and breaking changes :-) Herbert and Spankied 2 Quote Link to comment Share on other sites More sharing options...
Herbert Posted October 3, 2017 Author Share Posted October 3, 2017 Oh~I get it, I believe this will be quite useful sometimes. For the case that error message is preferred to be shown, is that possible to pass the error message to errorCallback? Quote Link to comment Share on other sites More sharing options...
RaananW Posted October 3, 2017 Share Posted October 3, 2017 Just think about the error callback as a one big try-catch. Any error inside will trigger it. So, error is "something went wrong while trying to do what you wanted", instead of "something went wrong with those specific assets". The error callback's second variable is a message coming from babylonjs (https://www.babylonjs-playground.com/#11BH6Z#316). The 3rd variable SHOULD be the exception, but I just found out that we are not calling the onError with the exception. I am fixing this now. Will that be enough? Quote Link to comment Share on other sites More sharing options...
Herbert Posted October 3, 2017 Author Share Posted October 3, 2017 Thanks @RaananW, as long as I can see the original message for development. What about assetManager? Any way I can catch the error message in onFinish? I print out the second and third variables of onTaskError, they are both undefined . var assetsManager = new BABYLON.AssetsManager(scene); assetsManager.addMeshTask("dude", "", "Scenes/Dude/", "Dude.babylon"); assetsManager.onFinish = function(task) { console.log(a.a); }; Quote Link to comment Share on other sites More sharing options...
RaananW Posted October 3, 2017 Share Posted October 3, 2017 Just made a few changes in the way we handle errors (or better yet - error callbacks) in both the loader and the assets manager. I want the rest of the team to review the changes before merging, but you can see the changes here - https://github.com/BabylonJS/Babylon.js/pull/2890 In general, message (string) and exception (any / error / js exception) were added to most onError callbacks. Quote Link to comment Share on other sites More sharing options...
RaananW Posted October 3, 2017 Share Posted October 3, 2017 Another update regarding this issue - AssetsManager now has better error handling (and 3 new observables to handle task success, error, and all tasks done). What's important in this case, is that if there is an error in the onSuccess callback (like in your case), an error will be displayed in the console. If you have an onError callback defined, you will actually get the exception thrown so you can dig further and understand what went wrong. The changes were just merged, I will build a nightly soon, so expect to see it in the playground pretty soon. Sebavan 1 Quote Link to comment Share on other sites More sharing options...
Herbert Posted October 5, 2017 Author Share Posted October 5, 2017 Thanks for super fast fix SceneLoader.ImportMesh works great. However, I still can't get the error message in onFinish callback(I tried the combination as shown below) Also, onTasksDoneObservable does not fire like onFinish while all tasks done. // task done assetsManager.onTaskSuccess = () => { console.log(a.a); }; assetsManager.onTaskSuccessObservable.add(() => { console.log(a.a); }); // catch error assetsManager.onTaskError = (i, j, k) => { console.log(i, j, k); }; assetsManager.onTaskErrorObservable.add((i ,j ,k) => { console.log(i, j, k); }); // all tasks done assetsManager.onTasksDoneObservable.add(() => { console.log(a.a); }); assetsManager.onFinish = () => { console.log(a.a); } Quote Link to comment Share on other sites More sharing options...
RaananW Posted October 5, 2017 Share Posted October 5, 2017 Got it! Let me see how to solve this in a nice way. Quote Link to comment Share on other sites More sharing options...
RaananW Posted October 5, 2017 Share Posted October 5, 2017 So, this PR is solving those issues - https://github.com/BabylonJS/Babylon.js/pull/2900 . But I need to discuss with the rest of the team and see what they think of the solution. Will keep this post updated. Sebavan and Herbert 2 Quote Link to comment Share on other sites More sharing options...
Herbert Posted October 6, 2017 Author Share Posted October 6, 2017 cool, looking forward to it~ Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted October 6, 2017 Share Posted October 6, 2017 Validated.. merged .. Publication in progress Excellent work RaananW 1 Quote Link to comment Share on other sites More sharing options...
dbawel Posted October 8, 2017 Share Posted October 8, 2017 @Herbert - I've found the assetsManager.onFinish to cause errors for several BJS versions all the way back to before 2.0. It often reports that all assets are loaded before it has finished and everything is actually cached. It happens most often in my scenes when I'm loading allot of small assets such as low res textures - especially when building GUIs and loading the assets to use in extensions. So I often find that once my scene is loaded, there are images missing from my scene and/or from the GUI. And since the AssetsManager loads in sequence, as logic dictates, it will always be the assets at the very end if the list which aren't loaded when my scene initializes when onLoad reports true. I gave up trying to solve this problem at least 2 years ago, and do have a work around. I create 2 or 3 very small power of two textures at 32px X 32px and simply call them "dummy_texture1.png", "dummy_texture2.png", and so on. These are never meant to be used, and in all of my testing, I've rarely seen the Assets Manager miss more than 1 or 2 textures at most. 2 appears to be the limit for me generally. I know this is a ridiculous solution, but I don't have another and can't have my scenes initializing with missing assets. So I place 2 or 3 of these tiny "dummy" textures at the end of my list of assets to load, and my scene is still often loaded before all assets are cached - however I receive no errors as the "dummy" textures are never called, and don't really use any resources to ever consider when they do load. Again, not a very eloquent solution, however I never have the problem of my scene initializing with missing assets - forcing the user to reload. And I'll mention again that I've worked on trying to solve this in every way I can think of down to memory allocation calls; but had to give up as I simply couldn't find a consistent solution. And I never want users to be forced to refresh their scenes due to missing textures and/or assets. Of course this generally happens when I'm loading allot of assets prior to scene initialization - but create and load small dummy textures to the end of the list and it will never happen. I hate to even mention that I do this routinely, but I've found no better choice personally. Cheers, DB Quote Link to comment Share on other sites More sharing options...
adam Posted October 8, 2017 Share Posted October 8, 2017 @dbawel Hopefully these fixes will help to resolve the issues you had been experiencing. dbawel 1 Quote Link to comment Share on other sites More sharing options...
RaananW Posted October 9, 2017 Share Posted October 9, 2017 If it can be reproduced, it can be fixed. If there is a bug somewhere, we just need it reported. I think the core team has proven to be serious bug-hunters. Quote Link to comment Share on other sites More sharing options...
Herbert Posted October 11, 2017 Author Share Posted October 11, 2017 hi @dbawel I haven't met any situation like yours since I don't really have many small assets to load. You can try the latest version, perhaps it is resolved by now. Quote Link to comment Share on other sites More sharing options...
Herbert Posted October 11, 2017 Author Share Posted October 11, 2017 @RaananW It works, now both error and exception are shown when an error occurs, and onTasksDoneObservable behave as expected. Thanks for your great work RaananW and GameMonetize 2 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.