I have a BIG issue with the new Widget 2.0 tableviews. First of all I appreciate all the hard work that went into the new Widgets, great job guys!!! But the new tableview from a performance stand point is horrible. The simple example running on the simulator works fine but once things get a little more complicated things go bad. If I take the example and add a sub text and instead of 100 rows I render 2000 things look ok in the simulator but on a device(retina iPad) the performance is horrible and slows down the whole UI as well as very bad scrolling. I understand that in a game 2000 rows might seem excessive but I’m using Corona for an EHR mobile app and having 2000 patients isn’t far fetched at all(we have a couple providers with a couple thousand) and this performance hurts. This wasn’t the case with the old widgets so this happening right near the end of development really throws a wrench in things. I’m sure the old widgets removed the row from memory when it was off screen and had better memory management. Is there something I can do to get better performance?
Here is a simple test case to see how performance struggles on a device. Note you have to install it on a device to see the poor performance.
local group = display.newGroup() local widget = require( "widget" ) screen = { left = display.screenOriginX, top = display.screenOriginY, right = display.contentWidth - display.screenOriginX, bottom = display.contentHeight - display.screenOriginY }; -- Handle row rendering local function onRowRender( event ) local phase = event.phase local row = event.row local rowTitle = display.newText( row, "This is displaying Row " .. row.index, 0, 0, nil, 14 ) rowTitle.x = row.x - ( row.contentWidth \* 0.5 ) + ( rowTitle.contentWidth \* 0.5 ) rowTitle.y = (row.contentHeight \* 0.5)-10 rowTitle:setTextColor( 0, 0, 0 ) local rowSubTitle = display.newText( row, "This is displaying Sub Row " .. row.index, 0, 0, nil, 12 ) rowSubTitle.x = row.x - ( row.contentWidth \* 0.5 ) + ( rowSubTitle.contentWidth \* 0.5 ) rowSubTitle.y = (row.contentHeight \* 0.5)+10 rowSubTitle:setTextColor( 93, 93, 93 ) end -- Handle touches on the row local function onRowTouch( event ) local phase = event.phase if "press" == phase then print( "Touched row:", event.target.index ) end end -- Create a tableView local tableView = widget.newTableView { top = screen.top, left = screen.left, width = (screen.right-screen.left), height = (screen.bottom-screen.top), onRowRender = onRowRender, onRowTouch = onRowTouch, } group:insert( tableView ) -- Create 2000 rows for i = 1, 2000 do local isCategory = false local rowHeight = 40 local rowColor = { 255, 255, 255 } local lineColor = { 220, 220, 220 } -- Insert the row into the tableView tableView:insertRow { isCategory = isCategory, rowHeight = rowHeight, rowColor = rowColor, lineColor = lineColor, } end