The blocks area did not load properly.

Hi,

I had a session opened from yesterday, I went to blocks editor and dragg a block. Suddenly, I saw a message saying: ...need to reload!

After reloading the page and selecting my account, a big amount of blocks I had in that screen desappeared.

Some one can help, please?

I'd tried exporting and importing the project on appinventor test page: https://ai2-test.appinventor.mit.edu/#5690035441500160, but as a result I get the same message.

Hi @Carlos_Campos_Sabori,

Are you willing to attach the exported project to this message? We can take a look and determine why the project might be failing to load.

AcuerdateDeLaPastillaAbuela1.aia (482.2 KB)

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