ESP32 with Matrix, IR and BLE: Guru Meditation Error

I want to add BLE to my ESP32. If a device connects, a variable is changed so that the matrix displays certain texts etc.
But once I added the BLE coding, my ESP went on a Guru Meditation Error, because Core 1 panic’ed. I removed all excess coding but still it won’t work. Only once I comment out the BLE descriptors in the void setup(), it runs.

How can I change my code so it won’t crash?

#include <Adafruit_GFX.h>   // Core graphics library
#include <P3RGB64x32MatrixPanel.h>
#include <IRremote.h> //this is a special one for ESP32, it won't work with Arduino
#include <BLEDevice.h>
#include <BLEServer.h>
#include <BLEUtils.h>

P3RGB64x32MatrixPanel matrix;

#define receiver 34
IRrecv irrecv(receiver);
decode_results results;

int var = 0;

#define SERVICE_UUID        "4fafc201-1fb5-459e-8fcc-c5c9c331914b"
#define CHARACTERISTIC_UUID "beb5483e-36e1-4688-b7f5-ea07361b26a8"
BLEServer* pServer = NULL;
BLECharacteristic* pCharacteristic = NULL;
bool deviceConnected = false;

void setup() 
{
  Serial.begin(115200);
  matrix.begin();

  irrecv.enableIRIn();
  matrix.println();

  delay(100);

  BLEDevice::init("ESP32");
  pServer = BLEDevice::createServer();
  //pServer->setCallbacks(new MyServerCallbacks());
  BLEService *pService = pServer->createService(SERVICE_UUID);
  pCharacteristic = pService->createCharacteristic(
                      CHARACTERISTIC_UUID,
                      BLECharacteristic::PROPERTY_READ   |
                      BLECharacteristic::PROPERTY_WRITE  
                    );
  pCharacteristic->setValue("");
  pService->start();
  BLEAdvertising *pAdvertising = BLEDevice::getAdvertising();
  pAdvertising->addServiceUUID(SERVICE_UUID);
  pAdvertising->setScanResponse(false);
  pAdvertising->setMinPreferred(0x0);  // set value to 0x00 to not advertise this parameter
  BLEDevice::startAdvertising();
  Serial.println("Waiting a client connection to notify...");
}//setup

void loop() 
{
    if (irrecv.decode(&results)) 
    {
        translateIR(); 
        irrecv.resume(); 
    }//if
    
    if (deviceConnected) {
        var = 1;
    }
    delay(200);
}//loop

void translateIR() 
{    
    switch(results.value)
    {      
        case 0xFF10EF:  
            Serial.println(" 4              ");
            matrix.fillScreen(matrix.color444(0,0,0));
            if(var==0) {
              matrix.setCursor(0,0);
              matrix.print("Disconnected");
            }
            if(var==1) {
              matrix.drawRect(15, 0, 47, 31, matrix.color444(15,15,15));
            }
        break;
    }//switch
    delay(200);
}//translateIR

Error message:

Rebooting...
Guru Meditation Error: Core  1 panic'ed (Interrupt wdt timeout on CPU1)
Core 1 register dump:
PC      : 0x4008112e  PS      : 0x00060034  A0      : 0x800811f6  A1      : 0x3ffbea30  
A2      : 0x3ffc4e50  A3      : 0x00020000  A4      : 0x00000017  A5      : 0x3ffba438  
A6      : 0x3ffc4eac  A7      : 0x3ffc4eac  A8      : 0x0000000b  A9      : 0x00000280  
A10     : 0x3ff44004  A11     : 0x00000005  A12     : 0x00000000  A13     : 0x00000000  
A14     : 0x00000046  A15     : 0x00000040  SAR     : 0x00000009  EXCCAUSE: 0x00000006  
EXCVADDR: 0x00000000  LBEG    : 0x40081086  LEND    : 0x40081141  LCOUNT  : 0x0000001d  
Core 1 was running in ISR context:
EPC1    : 0x4000bff0  EPC2    : 0x00000000  EPC3    : 0x00000000  EPC4    : 0x4008112e

Backtrace: 0x4008112e:0x3ffbea30 0x400811f3:0x3ffbea60 0x40081611:0x3ffbea90 0x40081a9d:0x3ffbeab0 0x4000bfed:0x00000000

Core 0 register dump:
PC      : 0x40082cd9  PS      : 0x00060c34  A0      : 0x800840fa  A1      : 0x3ffb9d80  
A2      : 0x00000000  A3      : 0x00000000  A4      : 0x3ffb7dbc  A5      : 0x00000000  
A6      : 0x00000000  A7      : 0x00000002  A8      : 0x00000000  A9      : 0x00000001  
A10     : 0x00000000  A11     : 0x130003e8  A12     : 0x00000000  A13     : 0x00000001  
A14     : 0x00060c20  A15     : 0x00000000  SAR     : 0x00000000  EXCCAUSE: 0x00000006  
EXCVADDR: 0x00000000  LBEG    : 0x00000000  LEND    : 0x00000000  LCOUNT  : 0x00000000  

Backtrace: 0x40082cd9:0x3ffb9d80 0x400840f7:0x3ffb9da0 0x40093099:0x3ffb9dc0

I can't understand all the error messages from the ESP32 but I'm kinda getting used to it... This panic message usually comes from array range exceeded.

So first look for that kind of problem.

If not relevant in your case, you should try to run the BLE examples provided in the libraries, then add your code to the correctly running example.

I started from the blank BLE sketch and added line for line the other code until it crashed..

In the void setup(), it crashes when performing

matrix.begin();
irrecv.enableIRIn();
BLEDevice::init("ESP32");

I guess I will have to move the matrix.begin(); and irrecv.enableIRIn(); to somewhere else, but where to place these?

I moved them into the loop and only run that part once.. problem solved

Good, but weird...