ESP32: Crash on printing to TFT inside a loop

Hello!
I have an ESP32 connected with a 3.5" TFT screen, using TFT_eSPI library.
I’m trying this code, but it seems that ESP32 crashes at some point:

// declarations 
// setup...

String text = "This is a sentence.";

void loop() {
      
    tft.setTextColor(WHITE, RED);   
    tft.setTextSize(2);    
    tft.setTextWrap(false);

    int x = 0;

      
    while (x < 480)  {
        tft.setCursor(480 - x, 5);
        tft.print(text);
        x = x + 1;
        Serial.println(x);
    }
     
    Serial.println("END");
}

Serial monitor shows just 0 and 1. Then nothing.
The “END” word never appears.
The TFT seems to print the first letter of the sentence on the right top, then freezes (just when serial monitor stops printing numbers) and a horizontal line appears from left to right at the top (there is no command in the code to print a line on the screen).
I cannot understand why this happens. Seems that ESP32 crashes within the loop and stops responding.
I know this is not the “right” way to scroll text, but why doesn’t it work (even with flickering, etc)?

Thank you in advance

        tft.setCursor(480 - x, 5);

What are the arguments to setCursor? Can your device really show 480+ characters on one line?

        tft.print(text);

Does print() accept a String?

Hello!
Thank you for your reply!

What are the arguments to setCursor? Can your device really show 480+ characters on one line?

This seems to be the issue...
But how can I do smooth scrolling if this is the case? I made it work, but I needed to move it about 8 pixels to the left, making the scrolling unsmooth.
I am seeking for a solution to move it pixel by pixel...

I am seeking for a solution to move it pixel by pixel...

A TFT isn't designed to display text. The library is handling the conversion of text to pixels to light up the pixels in such a way that what is displayed looks something like the text you expect to see.

You'd need to dig into the source code for the library to see how the pixels are determined, and see if there is a way, or add one if there is not, to move the whole collection of pixels one place to the left. You'd need to determine how to backfill the now-empty column on the far right.

Personally, I'd find it weird to have partial letters appear on the right edge of the screen, and to have partial letters remaining on the left edge.