klembot / twinejs

Twine, a tool for telling interactive, nonlinear stories
https://twinery.org
GNU General Public License v3.0
2k stars 295 forks source link

Story files with malformed positions aren't handled gracefully #591

Closed JenToksvig closed 2 years ago

JenToksvig commented 5 years ago

vanishinglinks.txt

When I select a passage, either with a single click or a double, all its link lines vanish.

I’m also finding passages scooting way over to the far left of the window. I can move them up or down, but not to the right: they stay along that side.

I found an old post which said that passages were moving completely off screen, and you said you had made it so a passage could not longer go entirely off screen, so maybe that thing is keeping them at the left side and it’s the same old problem?

This isn’t happening in all my stories. Just one, currently. The others, in the same story format, are working just fine.

I don't know how to reproduce. I had been working in the story just fine, making simple cutting and pasting edits within passages to move one bit of text above another in the prose, and then all of a sudden it start to go wrong.

NB: someone recommended using Twine 2.2.1 for now, so I installed it, and opened up the saved story file that was glitching. It still glitches in 2.2.1 - the link lines vanish when I click on a passage. Text file of the html attached.

App version Desktop app Twine 2.3.3 Sugarcube 2.28.2

Environment Mac OS Mojave 10.14.5 When opening the story in a browser, using Firefox 68.0.1 (64-bit)

HiEv commented 5 years ago

Looking at the file, some passages have weird floating-point values for their position. For example: <tw-passagedata pid="2" name="resident" tags="" position="2477.6666666666665,300" size="100,100"> and others have NaN ("Not a Number") for their position. For example: <tw-passagedata pid="4" name="root" tags="" position="NaN,NaN" size="100,100"> So it looks like the position data is getting corrupted somehow.

Was the story completely written in Twine v2.3.3? Or was it ever in another format, such as a Twee file put together with Tweego? If so, that might explain some of the oddness, because I've seen some similar weirdness in a Twee/Tweego file before.

In the mean time, you could manually check the "position" attribute for all <tw-passagedata> elements in the HTML in a text editor of some sort (like Notepad++), and replace any weird values with something more sane. Such as position="100, 100" (upper-left). Then import the modified file into Twine and with a new story name and hopefully it will stay fixed.

Hope that helps! :-)

JenToksvig commented 5 years ago

Hey - thanks for that. Yes, when I found a much older post on another forum about this, changing those values was the suggested fix. I actually rebuilt the whole thing into a new story the long-winded way.

The whole thing was written in Twine v2.3.3 yes, although I probably did some work in TextEdit too - which I always do as plain text. I'm just used to coding html that way.

The disappearance of the lines is so weird, and the most frustrating thing. Hopefully, raising the issue and having the file will help someone fix it.

TGFCoffee commented 5 years ago

This is happening on Windows 10, 64 bit also, with Chrome browser ver .76.0.3809.100. I wrote the stories in 2.2.1. Many passages appear missing when I open the story but the correct number of circles appear in the story icons on the home page. I'm going to have to revert back to the older version until this bug is fixed because I accidentally rewrote many passages before I realized it was a bug and not my forgetting to publish to file. 2.2.1 works fine for me.

klembot commented 5 years ago

Retitled this bug to be a bit more specific about what is going on. However it happened, Twine is having a lot of trouble with handling your passage positions as noted in the thread.

imset commented 4 years ago

Having this exact issue on Twine 2.3.5. Was editing an old story, one I've been working on for almost 2 years, and it just started occurring. Clicking on a passage causes all its arrows to disappear, and when I exit the story and re-enter it is sent to the far left of the screen. No other stories exhibit this property. The twine version I had edited this story on last was Twine 2.3.2, and I did not have this problem then. The problem is also exhibited in making new passages. All new passages are immediately spawned to the far left of the screen, without me having to click on them at all. After poking through the HTML file, it appears that it's like what HiEv was saying - the tw-passagedata for the messed up passages all look something like this:

tw-passagedata pid="270" name="rachelbookrec" tags="" position="undefined,2563" size="100,100"

Editing the undefined into a number is a temporary fix, but as soon as I click the passage again it went back to undefined and to the far left. I also looked through and could not find any with a value of NaN or long floating points, like what was pointed out by HiEv. Only undefined.

Another property is that when I click and drag to select multiple passages, undefined passages on the far left are automatically highlighted as long as the selection's vertical height would encompass them see here (the x-arrows have nothing to do with this bug). I'm guessing it's more of a symptom of the x coordinate being undefined rather than a cause but I thought I would mention it.

E: So after messing around with it for a bit, I duplicated the story (which still exhibited the bug), and then tried deleting ~200 random passages out of the near 300 I have in the story. After doing this, the bug seems to have disappeared from that story.

I then tried duplicating the original story again, this time I deleted 98 passages on the far right of the story. After doing that, I at first thought the bug disappeared again, but instead it seems to have morphed into something much stranger - only the top of the story would exhibit the property. I could make a new passage, click on them, anything as long as it wasn't in the top 4 "squares" of the story grid. As soon as something entered those top 4 squares, it started to exhibit the bug. Also strangely, every time I made another "bugged" passage, the top "bug zone" increased by about 1 square. So I'm guessing it was related to the number of passages I had, and it made the "bug zone" span the entire story.

singpolyma commented 4 years ago

Related issue: if I try to import a file with no position data at all (created by another tool), Twine just hangs.

HiEv commented 3 years ago

I should note that, based on what I've heard from others, it appears that this might be a bug in the scaling code which can sometimes corrupt the "position" data in a Twine file like this. I'd recommend not using the top menu/keyboard options to change the scale, and instead only use the three buttons on the bottom menu.

klembot commented 2 years ago

2.4 adds code to repair stories where passages with NaN positions are coerced to 0, so passages will be at least visible (if not positioned well) if they become corrupted.