Crash with large files and projects

Hi, whenever in a project there’s a long file ( i mean more then 400 lines, including comments ecc.) codea became very unstable. it became impossible to use the search functionaliy. it crashes as soon as I touch the button, and moreover it often crashes also while copying / pasting or making normal edit operations.

Hi @Simeon, i did some more investigation and i realized that the crashes are not related to large files or project with multiple files.

The problem arises if a closure function is passed as parameter of another function and for readibility the closure is defined on a new line.

Try to write the following code, close and reopen the project and if you press the search button… bum!

The most strange thing is that if you just write the code without closing and reopening the project the search button works fine.

function f1(f)
    f()
end

function setup()
     
    f1(
    function()print("hello")end)
     
end


function draw()

end

the same code written in this way instead cause no problem at all:

function f1(f)
    f()
end

function setup()
     
    f1(function()
    print("hello")end)
     
end


function draw()

end

Thanks for this report, @shrike. Is there any chance that you could email the file that causes the instability to us? (You can use the feedback email on the credits screen).

One more thing about the search functionality: it seems that it doesn’t recognise properly comments. For example, if in a comment I write “function”, the search will show me an anonimous function in that file!

That lead to another crash related to the function keyword and the search functionality.

The following code make codea crash (follow the same steps then before):

--[[
comment
function
--]]
-- Use this function to perform your initial setup
function setup()
    print("Hello World!")
end


function draw()
end

The following instead works fine:

--[[
comment
-function
--]]
-- Use this function to perform your initial setup
function setup()
    print("Hello World!")
end


function draw()
end

It has nothing to do with the crashes, but speaking about search, function and bugs, all the local function are enumerated as “Anonymous”.

Btw, after removing all the situation I’ve notified in the previous posts, now codea doesn’t crash anymore just opening the search panel, even on large projects.

Anyway the search functionality is very unstable, and codea crashes often when using it.

I have still to understand better if there’s any relations between large projects and/or files and crashes when just editing and copy/paste code.

The larger my project becomes, the more unstable search becomes. It’s gotten to the point where 50% of the time, search yields incorrect info and the other 50% it causes a crash. I’ve had to remind myself to stay away from that (very useful until now) button.

Thanks for the detailed reporting, @shrike, I’ll use your examples to find this bug.

@Mark what sort of incorrect results? Could the crashes you experience be related to @shrike’s?

Hi @Mark and @Simeon, After finding the bugs previously described I’m able to use search again. I’ve not seen particular wrong results (apart having local functions considered as anonymous), in mu experience the results are always correct. But the crashes are still so frequent, usually 1 of 3 search attempt leads to a crash if the project include lot of files with some of more then 300 lines

I don’t think my issue is clearly related to @shrike’s. So far as I can tell, I haven’t nested any function definitions or passed functions as an attribute.

What I’m getting is that increasingly the search ignores the contents of the search box and returns the values from a previous search. On other occasions, search simply causes a fail to the “desktop.”

I haven’t been able to fix the instability issue with large projects and searching (yet). As I am unable to recreate it on my largest project, Cargo-Bot. But hopefully I’ll discover this bug soon.

I have fixed @shrike’s crashing example though. Thank you for that.

Hi @Simeon, I can provide you a couple of large project where it happens so easily if you want to make some test.

Anyway from my experience the problem is not just related to make searches, it’s something related to ‘search and modify’ the code, like when refactoring. It happens frequently that looking for occurrences of a variable or a method that I want to change in the whole project, it crashes after I already did some changes. And it something that happens very easily if I do things quickly, I mean, if I work as I’m used to do with editor like visual studio. I noticed that if I go slowly, and I avoid to open search panel just after a change, with maybe an active selection, the number of crashes decrease significantly,

Anyway I’ve found another crash with reproducibility 100%, even with small projects (and I think it can be at the base of most of the problems)

repro steps:

1 open the search panel
2 select one of the enumerated functions
3 repeat points 1,2 (without touching the editor screen, leaving the 'function’word of the previous search selected)
4 BUM :slight_smile:

NB.

  • if you just select a ‘function’ keyword and make a search it doesn’t crash.

-if you instead do things between one search and the next, you got less probabilities of a crash.

-I’m using an iPad2 and I’ve encountered the problem with a lot of other apps in backround as well with just codea running,


I think that the most annoying problem is not the crash itself, but the risk to lose a lot of changes done before of the crash! In the last days I got used to execute current program after just a few changes to be sure to have my files saved, fearing for a crash.

I think that an explicit ‘save’ function would be really appreciated… At least by me :slight_smile:

Another way it happens me to crash (but not always) is if first I use search and I select one of the enumerates function, and soon after I use search again and I start to write in the search edit box. Codea freezes and in a while closes.