The blocks area did not load properly.

I see this in several screens …

How is it possible to assign a color to a layout alignment?

1 Like

Hi ABG,

the only important screens are Screen1 and scrHoy. The other are ready to eliminate.

There must be corruption in the .bky file for that screen.
The blocks image does not reflect much of what is in the .bky file.

scrHoy.bky.txt (102.3 KB)

I have no handle on where to find the start of the corruption, though.

While some one else might have better diagnostic skills looks to help, here is some loss mitigation and prevention for you …

  • Look for a recent .aia export file as a fallback.
  • Keep multiple versions of .aia file exports.
  • Keep block level .png downloads for all procedures and events, for incremental recovery via drag and drop into a fresh project screen.
  • upload your .aia export file into https://unchive.kodular.io/build/ to see the blocks that AI2 could not load, to help you recreate them anew in a new Screen or Project. Unchive can see more blocks in your screen than AI2 can.
  • Beware of unfiltered copy and paste into AI2 text blocks. They can corrupt a project.

@Carlos_Campos_Sabori I’ve taken a look at your project and have a pretty good handle of what’s going on conceptually. I will fix the issue and upload it here once I’m done.

Here’s the fixed version of the project. The issue is that you are using text blocks in many places they shouldn’t really be used, such as the indices of list lookups and in math operations. The real problem was that you entered the text “contador” into a text block plugged into a socket expecting a number. This causes App Inventor to fail to load the project. I changed this text block into a variable get block, which I think was your real intent. This is in the btnSoy Click handler.

AcuerdateDeLaPastillaAbuela1_fixed.aia (482.0 KB)

But even after I removed all blocks from the "scrHoy" screen, the error still occurred. Even after I removed all components / arrangements.

If the project fails to load, we disabling saving it so that it can’t get into an even worse state. You removed all the blocks, but since App Inventor won’t save it won’t fix the problem.

The underlying issue here is that when a check fails during project load, Blockly throws an exception and stops parsing the workspace at that point. This is why it appears as though many blocks disappear in spite of even the smallest of errors. Since we don’t want people to inadvertently lose blocks (e.g., you fix the one problem but half the workspace is gone), it’s safer to prevent editing and put up an error because at least then we can intervene.

I’ve put together a potential fix (which is how I repaired this project):

Thank you!

To set this up for the AI2 Issues FAQ, here is the code pattern to avoid,
as seen in the unchive tool ...

Bottom line: Do not use text blocks for indexing and math.
(adding to App Inventor Issues FAQ)

The logical and, or, not blocks reject text blocks at docking time. (The Shakespeare example).

Why not have the list indexing and math blocks reject text blocks at dock time?

It does. If you try this you will see that it doesn't even allow it to connect. The problem becomes when you have a text block that contains a number, e.g. "0", which we accept due to (your favorite) duck-typing, after which you change the valid value to an invalid value. I believe that this was fixed by @BeksOmega in #2037, but projects may still contain the problematic connections. The fix I linked above will handle the issue when loading projects that contain the bad code and mark the blocks as errors.

#2037 fixed a slightly different issue. That was a problem with number inputs showing text when they shouldn’t.

The problem where text blocks don’t get kicked still exists:
TextBlocks

But that shouldn’t be too hard to fix. I can definitely look into it!

Ok I’ve put up a pull request (#2177) to add the block bumping!
NewTextBlocks

If you guys have any other ideas for making this system better, I’m happy to work on stuff :slight_smile:

1 Like

Yes, I knew that, but I removed the blocks here:

@Anke This may have caused other problems depending on how Notepad saved the file. For example, if it included a line ending so that the file wasn’t completely empty (zero size), then App Inventor won’t know to regenerate it and will fail when it attempts to read the (now missing) XML. You could try deleting the .bky entirely, in which case the server should do the right thing.

1 Like

We probably can't make this runtime-foolproof, but all we need here is Blockly-foolproof.
This is the only Blockly-killer I've seen recently, so we're probably good for now.

1 Like

Aha, thank you, that was the reason I was wondering why I don’t see 0 here:

grafik

Hi, @ewpatton

I am a coder and I had created a professional app.
But after I completed it I went to check it on my phone, and it had some errors. It was 11 In the night so I went to sleep with my computer shut downed.
After I woke up, I went to debug my code but to my surprise, it showed me this message: (The blocks area did not load properly. Changes to the blocks for screen 6730568888090624_Screen1 will not be saved.) and all my effort was gone to waste.
Help me, as this error is continuously coming as I am writing my code.
If you wish to contact me, you can feel free to contact me at removed by Mod - please do not share private info - instead use PM

Regards,
Vihaan Patil

Since it is a professional app you made backups?

3 Likes