How to output gif image on ili 9341?

I have:
esp 32 s3 devkit c1, display ili 9341.
Gif is displayed only with the help of the bb_spi_lcd library. When trying to display with TFT_espi, the following appears in the serial monitor: "Guru Meditation Error: Core 1 panic'ed (StoreProhibited). Exception was unhandled".
And at the same time the frame rate is low, flickering is very visible.
I installed: PSRAM: OPI SRAM, flash mode: QUO (120MHZ), FLASH SIZE-16 MB
How to increase frame rate?
Sketch:

``` // ESP32-S3 BLE GIF Receiver
#include <bb_spi_lcd.h>  // Install this library with the Arduino IDE Library Manager

#include <SPI.h>
#include <FS.h>
#include <SD.h>
#include <TFT_eSPI.h>     // Include TFT library
#include <AnimatedGIF.h>  // Include GIF library
#include <NimBLEDevice.h>
#include <NimBLEServer.h>
#include <NimBLEUtils.h>

#define TFT_CS   10 //     10 or 34 (FSPI CS0)
#define TFT_MOSI 11 //     11 or 35 (FSPI D)
#define TFT_SCLK 12 //     12 or 36 (FSPI CLK)
#define TFT_MISO 13 //     13 or 37 (FSPI Q)

// Use pins in range 0-31
#define TFT_DC    7
#define TFT_RST   6
// define HSPI pins
#define HSPI_MISO 37//27
#define HSPI_MOSI 35//13
#define HSPI_SCLK 36//14
#define HSPI_SS 39//26

#define LED_PIN 3  // Built-in LED on most ESP32 boards
#define SD_CS 39   // SD card CS pin


#include "FS.h"
#include "SD.h"
#include "SPI.h"
#include "holo.h"

BB_SPI_LCD tft; // Main object for the display driver

AnimatedGIF gif;                  // Create AnimatedGIF object
// GIF to display
#define GifData holo // Change image to display (image name in gif_files\[image header file].h)

void setup()
{
  Serial.begin(115200);
  tft.begin(LCD_ILI9341, FLAGS_NONE, 50000000, 10, 7, 6, 3, 13, 11, 12); //
  tft.setRotation(LCD_ORIENTATION_90);                                     // Make sure you have the right orientation based on your GIF
                                                                         // or the GIF will show incorrectly, even garbage output
                                                                         // Values : LCD_ORIENTATION_0, LCD_ORIENTATION_90, LCD_ORIENTATION_180 or LCD_ORIENTATION_270
  tft.fillScreen(TFT_BLACK);

  AnimatedGIF *gif;
  gif = openGif((uint8_t *)GifData, sizeof(GifData));
  if (gif == NULL)
  {
    Serial.println("Cannot open GIF");
    while (true)
    {
      //  no need to continue
    }
  }

  while (true)
  {
    gif->playFrame(false, NULL);
  }
}

void loop()
{
  delay(1);
}

// Open Gif and allocate memory
AnimatedGIF *openGif(uint8_t *gifdata, size_t gifsize)
{
  AnimatedGIF *gif;
  gif = (AnimatedGIF *)malloc(sizeof(AnimatedGIF));
  if (gif == NULL)
  {
    Serial.println("Not RAM Enough memory for GIF structure");
    return NULL;
  }

  gif->begin(GIF_PALETTE_RGB565_BE); // Set the cooked output type we want (compatible with SPI LCDs)

  if (gif->open(gifdata, gifsize, GIFDraw))
  {
    Serial.printf("Successfully opened GIF; Canvas size = %d x %d\n", gif->getCanvasWidth(), gif->getCanvasHeight());
    Serial.printf("GIF memory size is %ld (%2.2f MB)", gifsize, (float)gifsize / (1024 * 1024));
    gif->setDrawType(GIF_DRAW_COOKED); // We want the Animated GIF library to generate ready-made pixels
    if (gif->allocFrameBuf(GIFAlloc) != GIF_SUCCESS)
    {
      Serial.println("Not Enough RAM memory for frame buffer");
      return NULL;
    }
    return gif;
  }
  else
  {
    printGifErrorMessage(gif->getLastError());
    return NULL;
  }
}

//
// The memory management functions are needed to keep operating system
// dependencies out of the core library code
//
// memory allocation callback function
void *GIFAlloc(uint32_t u32Size)
{
  return malloc(u32Size);
} /* GIFAlloc() */
// memory free callback function
void GIFFree(void *p)
{
  free(p);
}

// Draw callback from the AnimatedGIF decoder
void GIFDraw(GIFDRAW *pDraw)
{
  if (pDraw->y == 0)
  { // set the memory window (once per frame) when the first line is rendered
    tft.setAddrWindow(pDraw->iX, pDraw->iY, pDraw->iWidth, pDraw->iHeight);
  }
  // For all other lines, just push the pixels to the display. We requested 'COOKED'big-endian RGB565 and
  tft.pushPixels((uint16_t *)pDraw->pPixels, pDraw->iWidth);
}

// Get human-readable error related to GIF
void printGifErrorMessage(int errorCode){
  switch (errorCode){
  case GIF_DECODE_ERROR:
    Serial.println("GIF Decoding Error");
    break;
  case GIF_TOO_WIDE:
    Serial.println("GIF Too Wide");
    break;
  case GIF_INVALID_PARAMETER:
    Serial.println("Invalid Parameter for gif open");
    break;
  case GIF_UNSUPPORTED_FEATURE:
    Serial.println("Unsupported feature in GIF");
    break;
  case GIF_FILE_NOT_OPEN:
    Serial.println("GIF File not open");
    break;
  case GIF_EARLY_EOF:
    Serial.println("GIF early end of file");
    break;
  case GIF_EMPTY_FRAME:
    Serial.println("GIF with empty frame");
    break;
  case GIF_BAD_FILE:
    Serial.println("GIF bad file");
    break;
  case GIF_ERROR_MEMORY:
    Serial.println("GIF memory Error");
    break;
  default:
    Serial.println("Unknown Error");
    break;
  }
  }

UPD:
I tried other gifs. They display better, but is it possible to improve the display quality on the display?

Which verision of the Arduino IDE are you using and which version of Expressifs ESP32 core ?

Expressif have made quite a lot of 'changes' to their core recently and this has broken libraries such as the TFT_espi for image display.

Arduino version 2.3.6.
Expressifs ESP32 core version 3.0.2

If you revert Expressifs ESP32 core back to 2.0.14 then the gif stuff might work with the TFT_espi library, not tried it myself, but maybe its faster ?

Unfortunately, it didn't help. On the contrary, it made the situation worse, because the working library doesn't function with the downgraded version.