Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Outline crash at startup #39

Open
ifuchs opened this issue Sep 17, 2021 · 12 comments
Open

Outline crash at startup #39

ifuchs opened this issue Sep 17, 2021 · 12 comments

Comments

@ifuchs
Copy link

ifuchs commented Sep 17, 2021

Outline.trace
20210917 122744.565916 setup_tableview_swizzle
20210917 122744.572534 main
20210917 122744.573498 init
20210917 122744.620835 get_screen_size
20210917 122744.623932 get_screen_size
20210917 122744.794352 button_undo_enable
20210917 122744.796551 button_redo_enable
20210917 122744.814525 set_key_event_handlers
20210917 122744.830051 tableview_number_of_rows
20210917 122744.832999 layout
20210917 122744.833339 get_screen_size
20210917 122744.834677 tableview_number_of_rows
20210917 122745.817715 init2
20210917 122745.820967 button_files_action
20210917 122745.825080 files_action
20210917 122745.829540 set_font
20210917 122745.834794 tableview_number_of_rows
20210917 122745.837691 set_font
20210917 122745.842580 tableview_number_of_rows
20210917 122745.845454 set_font
20210917 122745.850299 tableview_number_of_rows
20210917 122745.853140 pick_open_callback
20210917 122745.939202 set_font
20210917 122745.940208 set_font
20210917 122745.941039 prms_save
20210917 122745.942142 open_log
20210917 122745.942769 undo_save
20210917 122745.945251 tableview_number_of_rows
20210917 122745.945649 tableview_cell_for_row
20210917 122745.947200 tableview_height_for_section_row
20210917 122745.953747 set_content_inset
20210917 122745.964020 set_content_inset

@cvpe
Copy link
Owner

cvpe commented Sep 17, 2021

Finally, this trace does not help me....sorry
The set_content_inset function only contains one line which could not crash. I already have thought to modify all my script without the ui.TableView by building my own scroll view and sub views for all rows.
Long work and one disadvantage: all cells have to be created at start, not when they are displayed, but I think that TableView generates some bugs.

@jsbain
Copy link

jsbain commented Sep 17, 2021

You might consider adding a trace at function exit for set_content_inset. Then at the exit of any function that calls set_content_inset -- that way you can isolate which section of code is crashing. Once you know it is between the exit of set_content_inset and the exit of some other function, you can add line by line traces in the questionable section

@jsbain
Copy link

jsbain commented Sep 17, 2021

I think the error is somewhere starting from row 3033 to end of function tableview_cell_for_row. It seems that height_for_cell_row must get called either in parallel or from cell_from_row -- so that's why content_inset is shown twice in a row -- once from the height function and once in th cell function. So segfault must be happening near the scrolling code which caused you problems before ... Just add some more trace logging in that area.

@cvpe
Copy link
Owner

cvpe commented Sep 17, 2021

@JonB I would like to be sure that the crash occurs each time there before.
But thanks for the advice.

@cvpe
Copy link
Owner

cvpe commented Sep 17, 2021

@ifuchs please, try to reproduce and tell us if same trace

@ifuchs
Copy link
Author

ifuchs commented Sep 17, 2021

Just crashed again. Here is outline.trace

20210917 165610.425576 setup_tableview_swizzle
20210917 165610.434594 main
20210917 165610.435416 init
20210917 165610.515113 get_screen_size
20210917 165610.519194 get_screen_size
20210917 165610.750453 button_undo_enable
20210917 165610.752303 button_redo_enable
20210917 165610.768369 set_key_event_handlers
20210917 165610.782258 tableview_number_of_rows
20210917 165610.787323 layout
20210917 165610.787802 get_screen_size
20210917 165610.789265 tableview_number_of_rows
20210917 165611.771684 init2
20210917 165611.777509 button_files_action
20210917 165611.781636 files_action
20210917 165611.787252 set_font
20210917 165611.794061 tableview_number_of_rows
20210917 165611.797049 set_font
20210917 165611.801847 tableview_number_of_rows
20210917 165611.804735 set_font
20210917 165611.809742 tableview_number_of_rows
20210917 165611.812679 pick_open_callback
20210917 165611.889053 set_font
20210917 165611.891277 set_font
20210917 165611.893261 prms_save
20210917 165611.896373 open_log
20210917 165611.897860 undo_save
20210917 165611.901933 tableview_number_of_rows
20210917 165611.902700 tableview_cell_for_row
20210917 165611.905772 tableview_height_for_section_row
20210917 165611.916077 set_content_inset
20210917 165611.932446 set_content_inset

@jsbain
Copy link

jsbain commented Sep 18, 2021

@JonB I would like to be sure that the crash occurs each time there before.
But thanks for the advice.
Looking at the code I wonder, do you need to have a separate input accessory view for each row? That seems maybe a little dangerous. Tableviewcells are not guaranteed to exist once they fall off the screen -- so if you were scrolling fast, I could maybe see some sort of race condition where you are referencing the cell, but it has already been deleted. You might try calling retain on the underlying objc object.
Or, I wonder if there isn't a way to have one shared input accessory, shared by all rows... I'll admit I don't know much about input accessories..

@JonB
Copy link

JonB commented Sep 18, 2021

Can you please stop tagging me in this.

@jsbain
Copy link

jsbain commented Sep 18, 2021

Oops -@cvpe note wrong name on GitHub :/.

@cvpe, it seems like if the only reason you are using a new object every text view is to get the row, you could also do that by attaching the row as an attribute to the text view, which you get as first responder. Since your accessory views never get deleted, you might just be running out of memory. (There is a way, iirc, to get the pyObject of the SUITextView object, though you have to change the restype and encoding)

@cvpe
Copy link
Owner

cvpe commented Sep 18, 2021

@jsbain you're right about sharing (if possible) the same input accessory view, and I'll try, but I don't think this is a problem. The trace shows that the crash occurs after only ONE row displayed (only once call to textview_cell_for_row), at begin of the run. And that would not explain that if @ifuchs runs another script before, the problem does not appear.
And I have an attribute of the TextView to store the row., see bb.row = row.

@ifuchs could you retry witH the v01.00 which has more detailed trace in textview_cell_for_row

@cvpe
Copy link
Owner

cvpe commented Sep 18, 2021

@ifuchs could you retry with the new v01.01 which, following @jsbain advice, only uses one InputAccessoryView shared by each TextView of all rows. I remember you this is needed for special promote/demote keys in keyboard for editing the outline.

@cvpe
Copy link
Owner

cvpe commented Sep 18, 2021

@jsbain "content_inset is shown twice in a row", for two different TextView objects, thus entirely normal.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants