Pop up console and irelevant plugin problems.

Discussion in 'Javascript/Plugin Support' started by Skurge, Mar 26, 2017.

  1. mogwai

    mogwai 1984 Veteran

    Messages:
    876
    Likes Received:
    578
    Location:
    Bassett Nebraska
    First Language:
    English
    Primarily Uses:
    RMMV
    Eureka! You've pinpointed it!
    Screen Shot 2017-03-31 at 12.27.29 AM.png

    I've added this line to KhasAdvancedGraphics.js
    PHP:
    if(command === undefined) return; // line 804
     

    Attached Files:

    #41
  2. Skurge

    Skurge " (GASP) What's going on!? " Veteran

    Messages:
    1,039
    Likes Received:
    200
    Location:
    Australia
    First Language:
    English
    Primarily Uses:
    N/A
    Ran that updated plugin through my project and it does appear to have fixed the issue! There are no more crashes upon entering the map room!

    Ran a few extra play tests to check if there was any issues, given the updated line of code it might not have had anything to do with the libs/pixi files- but the outdated files I feel might be causing a frame rate loss? If you could provide me your updated files ( if you are using steam) I could determine if that has any effects ( would do so myself but my steam client isn't giving me them :/ )
    My other guess is perhaps the Bind_Picture_To_Map is not updated to handle well with these changes, what are your thoughts on that plugin?

    I'm really happy to see this problem fading away, you have all been so very helpful and kind :)
     
    #42
  3. mogwai

    mogwai 1984 Veteran

    Messages:
    876
    Likes Received:
    578
    Location:
    Bassett Nebraska
    First Language:
    English
    Primarily Uses:
    RMMV
    Last edited: Mar 31, 2017
    #43
  4. Skurge

    Skurge " (GASP) What's going on!? " Veteran

    Messages:
    1,039
    Likes Received:
    200
    Location:
    Australia
    First Language:
    English
    Primarily Uses:
    N/A
    Origionally I only wanted Kha's Js for the fog effects, but soon after learning of the comparrisons I felt Kha's plugin would better suit my game since it's using alot of graphic demanding stuff I.e Lights, Fog, Rain changing colour the works. Since i'm pacing myself to work on a small island of the map first and getting all the essential system of things completed- I don't have to fall back and redo everything on a huge scale.

    Fortunately for me- the Map room actually turns off the lighting and fog with the map's note tags and relies on the picture binding for turf indication like the image below.[​IMG]

    Unfortunately I have no understanding how to check my files versions- there creation dates consist of 2015-2016 which I'm guessing is not the current updated versions.
     
    #44
  5. mogwai

    mogwai 1984 Veteran

    Messages:
    876
    Likes Received:
    578
    Location:
    Bassett Nebraska
    First Language:
    English
    Primarily Uses:
    RMMV
    It's the top line.
    PHP:
    /*!
     * pixi.js - v4.0.3
     * Compiled Wed Oct 12 2016 19:18:54 GMT+0300 (RTZ 2 (зима))
     *
     * pixi.js is licensed under the MIT License.
     * http://www.opensource.org/licenses/mit-license
     */
    Compiled js? Weird...
     
    #45
  6. Skurge

    Skurge " (GASP) What's going on!? " Veteran

    Messages:
    1,039
    Likes Received:
    200
    Location:
    Australia
    First Language:
    English
    Primarily Uses:
    N/A
    Ah yes I see it now... not sure what the compiled part means, the dates still don't add up to me. Should be dated 2017 somewhere atleast but nope.
     
    #46
  7. mogwai

    mogwai 1984 Veteran

    Messages:
    876
    Likes Received:
    578
    Location:
    Bassett Nebraska
    First Language:
    English
    Primarily Uses:
    RMMV
    I've seen this happen a few times. Notice the Epochs date?
    [​IMG]

    It drives me nuts because I'm a little OCD about sorting by date-modified/created.

    It happens when copying files to external harddrives.
     
    #47
  8. Khas

    Khas Detective lv73 Veteran

    Messages:
    282
    Likes Received:
    374
    Location:
    Brazil
    First Language:
    Portuguese
    Primarily Uses:
    RMMV
    Okay, since I've been mentioned in this thread, let me clarify some stuff:

    1) In order to implement plugin commands, one must alias the function Game_Interpreter.prototype.pluginCommand, which receives the command and the arguments when called.

    2) This function is indeed aliased by my Advanced Graphics plugin:
    Code:
    ...
    Khas.AL_Game_Interpreter_pluginCommand = Game_Interpreter.prototype.pluginCommand;
    Game_Interpreter.prototype.pluginCommand = function(command, args) {
        var handled = false;
        switch (command.toLowerCase()) {
            case "lighting":
    ...
    3) The command parameter is expected to be a String, thus I used the .toLowerCase() method on the command parameter, so it's easier to check which command the user is calling

    4) However, for some reason completely unrelated to my plugin, the command variable is been passed as undefined or null. Then the crash happens and you see that error.

    5) Please note that my plugin is the first on your plugins list, so it's also the first to alias the Game_Interpreter.prototype.pluginCommand function. This means it's the last to receive the plugin command and args variables, so a lot can happen between the user calling a plugin command and the function being executed in my plugin.

    6) My conclusion is that one of the two things below is happening:
    a) RPG Maker may pass command as undefined/null, then every plugin maker must check them before using. If this is the case, it's indeed my error and I should have added a safety check before using the parameters.
    b) RPG Maker passes command as a string, always. Then some plugin in the middle is doing something weird with the parameters and passing them forward as null/undefined. If this is the case, even if my plugin didn't crash (supposing it had a safety check), you would have a buggy plugin somewhere doing things it isn't supposed to do.



    My point is that I already explained here what the problem was and that I will add a safety check to make my plugin more robust, even if this isn't my fault (again, my plugin is only showing that there's something wrong). I understand that plugin compatibility can be frustrating sometimes, but I wanted to make sure everyone on this thread understands what is happening and what the true problem is.

    TL;DR; Always check the Game_Interpreter.prototype.pluginCommand parameters before using them xD



    I've added a safety check in the next version of AdvancedGraphics, which will be released in a few days :)
    Thanks for your patience, and please let me know if you have any further questions!
     
    #48
    Quxios likes this.
  9. mogwai

    mogwai 1984 Veteran

    Messages:
    876
    Likes Received:
    578
    Location:
    Bassett Nebraska
    First Language:
    English
    Primarily Uses:
    RMMV
    Gotta write your script defensively.

    Harmony among a 100 other plugins is way out of my league, but I know what to do when I see a type error. Gotta check that variable == and its type ===.

    His game has real moving cars traffic. It's kind of a metaphor for his mass state of plugins if you think about it.

    I'm more of a country driver in that sense. (and if I drove like I write script well... I wouldn't have a license...)
     
    #49
    Khas likes this.
  10. Quxios

    Quxios Veteran Veteran

    Messages:
    1,055
    Likes Received:
    779
    First Language:
    English
    Primarily Uses:
    RMMV
    Even so, I don't think you should go with mogwai's fix. You should look through your plugins to see which one isn't passing the parameters into the alias, as that can break other plugins as well.
    From your earlier post: https://forums.rpgmakerweb.com/inde...-irelevant-plugin-problems.76399/#post-717345
    (Haven't gone through the whole thread so might be a newer console log)
    You should go through the list of plugins in the error trace, before Khas's to see if they passed correctly. So check "Izy VehicleRadio.js" if they passed the parameters into the alias if they did, make sure they didn't change the parameters, those parameters should be treated as immutable for compatibility purposes.

    As for the pixi version, v4 was released last year and I don't think MV has updated their pixi version since ~1.3. But with the community corescript, it'll probably start being updated more frequently.
     
    #50
    Khas likes this.
  11. mogwai

    mogwai 1984 Veteran

    Messages:
    876
    Likes Received:
    578
    Location:
    Bassett Nebraska
    First Language:
    English
    Primarily Uses:
    RMMV
    The plugin that makes the conflict is checking type. It's the more fundamental one.
    PHP:
       var _Game_Interpreter_pluginCommand =
               
    Game_Interpreter.prototype.pluginCommand;
       
    Game_Interpreter.prototype.pluginCommand = function(commandargs) {
           
    _Game_Interpreter_pluginCommand.call(thiscommandargs)
           var 
    args args || [];
           if (
    command === 'BindPictureToMap')         this.bindPictureToMap(args[0], trueargs[1]);
           if (
    command === 'UnbindPictureFromMap')       this.bindPictureToMap(args[0], falseargs[1]);
           if (
    command === 'ChangePictureLayer')       this.changePictureLayer(args[0], args[1]);
           if (
    command === 'START_BindPicturesToMap')  this.bindAllPicturesToMap(args);
           if (
    command === 'STOP_BindPicturesToMap')   this.stopBindAllPicturesToMap();
       };
    And this is the command for reasons I don't know throws in an undefined.
    Code:
    Bind_picture_to_map 1 above_characters
    EDIT: I think he is misspelling the command after all this hubbub.

    Does the call/apply of the original plugin manager first instead of last, turn underscores into camelCaps? I can't seem to figure out why that is the command.
     
    Last edited: Apr 2, 2017
    #51
  12. Skurge

    Skurge " (GASP) What's going on!? " Veteran

    Messages:
    1,039
    Likes Received:
    200
    Location:
    Australia
    First Language:
    English
    Primarily Uses:
    N/A
    Forgive me if I don't understand the code language and meaning behind them but I'm afraid I don't understand the request Mogwai.

    I appreciate all the hard work to help me fix these issues, Khas is working hard on new updates for the plugin and I am excited to try them out when completed, referring to Quxious I believe I had made later console reports but at this stage those errors had been fixed.
    Really do appreciate the fixes Mogwai has thrown in aswell- you have all been so helpful!

    I'm likely to get a new computer very soon and with the added software I should be able to record my progress via video/gif to really showcase some of the functions.
     
    #52
  13. mogwai

    mogwai 1984 Veteran

    Messages:
    876
    Likes Received:
    578
    Location:
    Bassett Nebraska
    First Language:
    English
    Primarily Uses:
    RMMV
    @Skurge
    I don't understand these plugin manager commands, but looking at the script something about Khas's plugin calling the aliased function last is snagging something undefined and the other plugin calling the aliased function first is coming out with its nose clean and it's somehow getting "BindPictureToMap" as the command, from your "Bind_picture_to_map", like underscores are cleansed. It's just food for the script.

    I like to make my scripts run from event script calls so I don't have to bloat the plugin manager.

    EDIT: It's about the order of the script inside their functions, not the order of your plugins. My guess is that the default plugin command takes 0 arguments from time to time by default, and khas doesn't call the default function until after his script runs so he catches an undefined.

    EDIT EDIT: Yep. This is correct. I just checked and even the default plugin manager is set up to avoid undefined arguments, but Khas's plugin is not, yepper.
    PHP:
    PluginManager.parameters = function(name) {
        return 
    this._parameters[name.toLowerCase()] || {}; // notice the || or statement
    };
    I don't know why my fix is taking heat from @Quxios . That's how it's supposed to work.
     
    Last edited: Apr 2, 2017
    #53
  14. Quxios

    Quxios Veteran Veteran

    Messages:
    1,055
    Likes Received:
    779
    First Language:
    English
    Primarily Uses:
    RMMV
    @mogwai First "PluginManager.parameter" is unrelated to the "Game_Interpreter.prototype.pluginCommand" errors. The issue is that with your fix Skurge will never be able to use any of khas plugin parameters since its undefined and will always ignored khas's commands. The other issue without finding the plugin that's causing it is that the same issue can appear again if skurge adds more plugins.

    The issue is that one of skurges plugins has a "bad alias" (probably on accident). For example they might have:

    Code:
      var _Game_Interpreter_pluginCommand =
               Game_Interpreter.prototype.pluginCommand;
       Game_Interpreter.prototype.pluginCommand = function(command, args) {
           _Game_Interpreter_pluginCommand.call(this);
           var args = args || [];
           if (command === 'BindPictureToMap')         this.bindPictureToMap(args[0], true, args[1]);
           if (command === 'UnbindPictureFromMap')       this.bindPictureToMap(args[0], false, args[1]);
           if (command === 'ChangePictureLayer')       this.changePictureLayer(args[0], args[1]);
           if (command === 'START_BindPicturesToMap')  this.bindAllPicturesToMap(args);
           if (command === 'STOP_BindPicturesToMap')   this.stopBindAllPicturesToMap();
       };
    * Note I didn't pass command and args into the alias

    Or maybe they mutated arguments even though they should be treated as immutable for compatibility, ex:

    Code:
      var _Game_Interpreter_pluginCommand =
               Game_Interpreter.prototype.pluginCommand;
       Game_Interpreter.prototype.pluginCommand = function(command, args) {
           var args = args || [];
           var arg1 = args.shift(); // mutate the args arr
           var arg2 = args.shift();
           if (command === 'BindPictureToMap')         this.bindPictureToMap(arg1, true, arg2);
           if (command === 'UnbindPictureFromMap')       this.bindPictureToMap(arg1, false, arg2);
           if (command === 'ChangePictureLayer')       this.changePictureLayer(arg1, arg2);
           if (command === 'START_BindPicturesToMap')  this.bindAllPicturesToMap(args);
           if (command === 'STOP_BindPicturesToMap')   this.stopBindAllPicturesToMap();
           command = null; // mutate the command var
           _Game_Interpreter_pluginCommand.call(this, command, args);
       };
    This probably isn't the case, but never know. The issue is probably the first, where someone plugin forgot to pass the arguments into the alias. Sometimes I forget to do that too! I even checked my plugins that skurge used just incase it was me lol.

    But don't get me wrong, checking the arguments is good to do, but the pluginCommand func should never pass undefined arguments if it does then that's a problem. But all this is just extending on what Khas had said:
     
    #54
  15. mogwai

    mogwai 1984 Veteran

    Messages:
    876
    Likes Received:
    578
    Location:
    Bassett Nebraska
    First Language:
    English
    Primarily Uses:
    RMMV
    He's right again. This pot roast better simmer down.
    SRD_FullscreenToggleOptions.js line 131. @SumRndmDde
    PHP:
        var _Game_Interpreter_pluginCommand Game_Interpreter.prototype.pluginCommand;
       
    Game_Interpreter.prototype.pluginCommand = function(commandargs) {
           
    _Game_Interpreter_pluginCommand.call(this);

           if(
    command.toLowerCase() === 'togglescreentype') {
               
    Graphics._switchFullScreen();
           }
       };
    I'm more a fan of
    PHP:
    return this.alias.apply(thisarguments);
    myself. It doesn't matter if it doesn't return.

    Now I'm wondering how this script even works.

    @Quxios You were right. I Just GREP searched that example you posted in 48 plugins.

    EDIT: I also think he failed to download your QCamera.js because it's in HTML.
    Screen Shot 2017-04-02 at 9.28.05 PM.png
     
    Last edited: Apr 3, 2017
    #55
    Quxios likes this.
  16. Skurge

    Skurge " (GASP) What's going on!? " Veteran

    Messages:
    1,039
    Likes Received:
    200
    Location:
    Australia
    First Language:
    English
    Primarily Uses:
    N/A
    Aside from waiting on Khas's next update: what would be the recommended next course of action to avoid further crashes?
     
    #56
  17. mogwai

    mogwai 1984 Veteran

    Messages:
    876
    Likes Received:
    578
    Location:
    Bassett Nebraska
    First Language:
    English
    Primarily Uses:
    RMMV
    Disable the fullscreen script. Just use the F4.

    And Re-download QCamera.js from Github, because you saved the HTML somehow.
     
    #57
  18. Skurge

    Skurge " (GASP) What's going on!? " Veteran

    Messages:
    1,039
    Likes Received:
    200
    Location:
    Australia
    First Language:
    English
    Primarily Uses:
    N/A
    Alright, re downloaded QCamera and QAudio and have those issues resolved. I think that all leads to Khas's impeding update :)
     
    #58
  19. SumRndmDde

    SumRndmDde Follower of RNGesus Veteran

    Messages:
    224
    Likes Received:
    410
    Location:
    an alternate dimension.
    First Language:
    English
    Primarily Uses:
    RMMV
    @mogwai
    Oh god, how embarrassing. >.<
    Sorry for the bug, it's a pretty old plugin. Thanks for pointing it out!
     
    #59
  20. mogwai

    mogwai 1984 Veteran

    Messages:
    876
    Likes Received:
    578
    Location:
    Bassett Nebraska
    First Language:
    English
    Primarily Uses:
    RMMV
    @SumRndmDde
    Don't sweat it. It comes with the package.

    I crash the game almost every line I write, because I'm more of a tinkerer than a programmer.

    If people were even using my plugins, I'm sure there would be bug reports for years.
     
    #60

Share This Page