Cannot read property Bug

Discussion in 'Javascript/Plugin Support' started by YunaLoire, Nov 19, 2017.

  1. YunaLoire

    YunaLoire Villager Member

    Messages:
    6
    Likes Received:
    0
    Location:
    Germany
    First Language:
    German
    Primarily Uses:
    RMMV
    Hey everyone!

    When I test run my game it says: "Type Error, Cannot read property 'id' if null". This also happens when I start a new game. I'm fairly new to RPG Maker and don't know much about Javascript, but I have some plugins installed. I was working on my project all day and everything worked fine until now.

    This is the F8 information:
    [​IMG]


    This is my plugin list:
    [​IMG]


    [​IMG]
    From what I can tell, something with my Yanfly's Doodads Plugin is wrong. When I turn it off, everything works, but I've put hours into designing my maps with this plugin, thus I'd appreciate it if someone could help me so that I can keep my maps as they are. Especially because everything worked fine, even with the plugins installed as they are right now. I haven't installed anything new, the only thing I did since the last time I'm pretty frustrated right now, any help is appreciated.
     

    Attached Files:

    #1
  2. Joy Diamond

    Joy Diamond Talkative Veteran

    Messages:
    135
    Likes Received:
    172
    First Language:
    English
    Primarily Uses:
    RMMV
    Greetings & welcome to the forums, YunaLoire,

    Nice to have you join us :)

    Your bug report is quite good for a first bug report:
    • I'd like to help you improve it.
    • The better your bug report, the easier someone can help you.
    • It will make it easier for them to reproduce the bug & then squish it.
    First of all you are using 8 plugins which are enabled (and one that is disabled):

    upload_2017-11-18_21-30-11.png
    From your stacktrace you posted, the bug is certainly triggering in YEP_GridFreeDoodads (which means it might be in Yep_GridFreeDoodads or in another plugin that is messing up GridFreeDoodads):

    upload_2017-11-18_21-33-32.png

    Now then:
    • Other than YEP_GridFreeDoodads, how many of the other plugin's can you turn off & still reproduce the bug?
    • If you could post a new screenshot, with just the minimal ones enabled, that will be the first step in helping others reproduce your bug.
    • (This might take you about half an hour or so)
    Also one more question:
    • I thought you had to use the Yanfly core with any other Yanfly plugins?
    Thanks,

    Joy Diamond
     
    Last edited: Nov 19, 2017
    #2
    YunaLoire and Llareian like this.
  3. YunaLoire

    YunaLoire Villager Member

    Messages:
    6
    Likes Received:
    0
    Location:
    Germany
    First Language:
    German
    Primarily Uses:
    RMMV
    Thank you for your kindness and warm welcome. And thank you so much for helping me!

    At first, I turned off the latest plugin I've installed: "YEP_MessageCore", then run the test game again and it worked perfectly fine. I can now create a new file and I can continue my old test file without any issues.
    I thought it was weird because these two plugins worked without any issues all the time, so I turned the "MessageCore"-Plugin on again, test run the game and it still works as if nothing has ever happened. So, in the end, I changed nothing and it works again.

    What can be the cause of such a problem except of another plugin? Sure, I'm just happy that this issue seems to have resolved itself, but I'm pretty curious about it since I use the Doodads Plugin a lot and I never had an issue with a plugin before.

    And I don't know whether I need the Yanfly core for Yanfly plugins, but most of my plugins are from Yanfly and I had no issues. This is my first project and I have practically no idea about anything, and the only thing I know about plugins is how to install and use them. But maybe I should install the Core Plugin to prevent future issues?
     
    #3
  4. Llareian

    Llareian Jack of All Trades, Master of None Veteran

    Messages:
    603
    Likes Received:
    1,400
    Location:
    USA
    First Language:
    English
    Primarily Uses:
    RMMV
    @Joy Diamond , just thought I'd pop in and answer your one question about Yanfly Core Engine: Yanfly Core Engine is not required for a (surprisingly) large number of Yanfly plugins, including the ones listed here. So that doesn't seem to be the problem. Also, great advice about bug reporting and checking for plugin incompatibility!

    And if I may add a couple more things for @YunaLoire , first of all, your Yanfly plugins usually need to be installed in a specific order. The order is the same as their listing on the Yanfly Engine homepage. Drag your plugins into the correct order to see if that fixes your problem.

    Also, Yanfly's Grid Free Doodads v1.06 requires RPG Maker v1.30 or above, so please make sure that your project's /js/rpg_core.js file is at least version 1.30. If you open the file in notepad, you'll see the version number right at the top of the file. (Though as Joy Diamond has indicated, it's also possible there's a plugin compatibility problem.)
     
    #4
    YunaLoire and Joy Diamond like this.
  5. Shaz

    Shaz Veteran Veteran

    Messages:
    37,809
    Likes Received:
    11,518
    Location:
    Australia
    First Language:
    English
    Primarily Uses:
    RMMV
    The issue is in the Grid Free Doodads Make Command List method. IIRC you need to save a .json file from Yanfly's site to the correct place in your project (I think it's the data folder) when you add the plugin. Did you do this?
     
    #5
    YunaLoire likes this.
  6. YunaLoire

    YunaLoire Villager Member

    Messages:
    6
    Likes Received:
    0
    Location:
    Germany
    First Language:
    German
    Primarily Uses:
    RMMV
    @Llareian , I didn't know they needed to be installed in a specific order, I reordered them but sadly this didn't solve the problem. My version is 1.5.1, so that shouldn't be the cause too.. But thank you very much!

    @Shaz , I'm pretty sure I followed the instructions from Yanfly's video. I actually watched it again and I remember that I needed to copy files into the data and the img folder. But thank you nonetheless!

    So, since it magically worked again, I continued to work on my project today, but suddenly after I saved, RPG Maker crashed and when I opened it again, it said: "Failed to load Animation.json". I googled it and followed the instructions from an another thread and made a backup of the corrupted Animation.json and replaced it with a backup file from the same project. The project works again, but the "Type Error, Cannot read property 'id' if null"-Error came back when I tried to run a test game.

    Basically, I have the same issue again and I don't know how that issue had magically solved itself last time.. and I'm also wondering about what can corrupt the animations.json like that.. the only thing I had done before saving was writing some text for an event and then fixing their direction.

    Thank you all very much for your time,
    YunaLoire
     
    #6
  7. Andar

    Andar Veteran Veteran

    Messages:
    28,643
    Likes Received:
    6,584
    Location:
    Germany
    First Language:
    German
    Primarily Uses:
    RMMV
    1) "failed to load XYZ.json" always means that something on your computer damaged the file.
    Usually this happens when Windows crashes, or if you poweroff without complete shutdown procedures, but it could also be that you're working on your project while it is in a cloudspace or a few other reasons.

    Find out which is the case and make sure it doesn't happen again, because this can destroy your work to the last backup.

    2) can you give an other Screenshot of your current Plugin manager after the reordering?
     
    #7
    YunaLoire likes this.
  8. YunaLoire

    YunaLoire Villager Member

    Messages:
    6
    Likes Received:
    0
    Location:
    Germany
    First Language:
    German
    Primarily Uses:
    RMMV
    Thank you, @Andar !

    So, Windows didn't crash, but the software crashed (just after I had saved my work). The project also isn't in a cloud space, I use the steam version of RMMV and to be sure I even checked whether it uses Steam's cloud sync system and whether that might cause a problem, but it doesn't use it. I'm quite "familiar" with corrupted files from modding experience, that's why I backup pretty often, but I never had the issue that something suddenly corrupted without any obvious reason like, as you've mentioned, windows has crashed.

    And here's the other screenshot:

    [​IMG]

    I also removed the plugin that was turned off, because I never really used it and didn't need it anymore. (It was the "YEP_FootstepSounds"-Plugin)

    Thanks again!

    EDIT:

    I tried how many of my installed plugins (not included: "MadeWithMV" and "Community_Basic"), other than the Doodads-Plugin, I could turn off and still reproduce the bug. The bug appeared even when I had no other plugins than the doodads-Plugin and the before mentioned plugins on. The only way to test run the game was to turn off the Doodads-Plugin, then, the other plugins worked. I hope there's a way I can solve this issue and continue to use the Doodads-Plugin. Without it, my maps are pretty empty now.

    EDIT 2:

    I found a backup folder that was made right after the issue had been solved last time. So, I made a copy of the backup and tried whether the bug occurs, and the test run worked. Between that backup and the current state of the project, I had only added two new maps and redesigned one, which I tried to import one after one to the copy of the backup (Just the maps, not the "MapInfos.json").

    I started with the redesigned map and it worked and I could still test run the game with the plugin running. I added one of the new maps and it still worked, the doodads weren't visible of course, since they're saved in the "MapInfos.json" (Not entirely sure though?), but it worked. But then, when I imported the last one, the bug appeared again. Then I deleted the map again and the bug disappeared.

    Can a map cause such a problem? If so, why did the bug disappear last time even though I hadn't done anything or deleted any maps? And what could I do to prevent such a bug from happening?


    EDIT 3:

    Okay, it was definitely the map. I deleted the map from the real project, not the backup file, and now it works again.
    But the questions remain the same. What does one map have to do with a bug regarding a plugin and how can I prevent this from happening in the future?
     

    Attached Files:

    Last edited: Nov 22, 2017
    #8
  9. Joy Diamond

    Joy Diamond Talkative Veteran

    Messages:
    135
    Likes Received:
    172
    First Language:
    English
    Primarily Uses:
    RMMV
    Greetings @YunaLorie,

    I just reread all your posts & you have put a lot of effort into figure out what is wrong.

    Answering this question would require even more effort on your part; but would be very educational for you.

    The first thing would be for you to learn how to use the debugger when you get the errors such as:
    If you feel that is a good investment of your time:
    • I'll be glad to do a google document together with you on how to use the console, that will help you & then in the future, will also assist others.
    • This document would use the MIT license, so we can freely share it with the community after it is made.
    If you have any questions, please feel to ask & I'll be happy to answer them.​

    Let me know if you are interested please,

    Joy Diamond.
     
    #9
  10. tito

    tito Villager Member

    Messages:
    10
    Likes Received:
    4
    Location:
    São Carlos, Brazil
    First Language:
    Portuguese
    Primarily Uses:
    RMMV
    Thank you for all of your information.
    I got the same problem here. Just started my first game in RMMV and got the very same issue with the Doodads plugins.
    Exactly the same.
    That is a great problem because I am at an already advanced stage of my project and cannot start it all over again.
     
    #10
  11. YunaLoire

    YunaLoire Villager Member

    Messages:
    6
    Likes Received:
    0
    Location:
    Germany
    First Language:
    German
    Primarily Uses:
    RMMV
    Thank you again, @Joy Diamond!

    I'm terribly sorry that I haven't replied earlier, I wasn't online for a while due to exams, and I hadn't received a mail/notification about your latest reply. I feel really bad since you've helped me so much and I'm grateful for your time and effort. Your replies were really informative, not only about the issue itself, but also about getting started on the forum!

    If you're still interested in writing a google document together with me, I'd gladly agree, but there's a problem. The problem is that I'm currently still taking exams for the next few weeks and until January I won't have the time to invest in that topic without having to worry about my grades.

    But I appreciate any opportunity that teaches me something new, and I'm always happy to help others. Especially since I've read so many threads regarding that same issue, which usually ended with the original poster having to redo their project. I'm grateful that it turned out well for me and I want to give something back to the community.

    So, if you're still interested and it would be possible for you to wait until next month, I'd be really glad to accept your kind offer!

    Thank you so much and I'm still sorry,
    Yuna Loire
     
    #11
  12. YunaLoire

    YunaLoire Villager Member

    Messages:
    6
    Likes Received:
    0
    Location:
    Germany
    First Language:
    German
    Primarily Uses:
    RMMV
    Greetings @tito ,

    I'm sorry that you have to face the same, frustrating issue. I don't know how I resolved that issue the first time, but I definitely know that the second time something had happened to the latest map I had created, which caused the issue. I'm by no means an expert, and I'd want to help you, but the only thing I can recommend is to back up your project and delete the last map you've worked on. Maybe it works, but maybe it won't, but then you'll still have the backup! Have you tried to reorder your plugins, like I had been advised to?

    I hope that you'll be able to resolve this issue and save your project,

    Yuna Loire
     
    #12
  13. Joy Diamond

    Joy Diamond Talkative Veteran

    Messages:
    135
    Likes Received:
    172
    First Language:
    English
    Primarily Uses:
    RMMV
    January is fine, I'll look forward to it.

    Best wishes on your exams :cool:
     
    #13
  14. LordS3B

    LordS3B Villager Member

    Messages:
    12
    Likes Received:
    3
    Location:
    Lima, Peru
    First Language:
    Spanish
    Primarily Uses:
    RMMV
    I think I've discovered what happened. The plugin tries to get each map's data by reading MapInfos.json, which follows this structure:
    upload_2017-12-10_15-9-23.png
    When you delete a map that is not the last ID, one of these lines gets changed by a null. And when the plugin tries to read the property id of the null object, it triggers the error because well... a null object doesn't have any property. When you deleted the map you said, I guess the MapInfos lines got in order again and the thing worked again. I'll try to edit the plugin so it skips every null object in the MapInfos file.
    UPDATE: I edited the Doodads plugin, deleted a map so the null appears in MapInfos, playtested, and it WOKED!!!! I'll PM Yanfly so he knows about that.
     
    Last edited: Dec 11, 2017
    #14
  15. Shaz

    Shaz Veteran Veteran

    Messages:
    37,809
    Likes Received:
    11,518
    Location:
    Australia
    First Language:
    English
    Primarily Uses:
    RMMV
    If that is indeed what is causing the problem, please make sure you post in Yanfly's plugin thread, with a link back to this one, so he is aware of the issue and what causes it. I think the fix should be pretty simple (checking that the object is not null before doing something with it) but I haven't looked at the code.

    Yanfly will then be able to update the original plugin so everyone benefits, rather than needing a patch to make it work without error.
     
    #15
  16. LordS3B

    LordS3B Villager Member

    Messages:
    12
    Likes Received:
    3
    Location:
    Lima, Peru
    First Language:
    Spanish
    Primarily Uses:
    RMMV
    My fix worked. It's just a matter of putting 5 lines inside a conditional so they don't trigger on a null object. Will post in in the thread right now.
     
    #16

Share This Page