-
Notifications
You must be signed in to change notification settings - Fork 437
Open
Description
Describe the bug
Crash EXC_BAD_ACCESS on iOS on long code snippet (more 75 lines of code and 3200 symbols) with highlighting
Checklist
- I can reproduce this issue with a vanilla SwiftUI project.
- I can reproduce this issue using the
main
branch of this package. - This bug hasn't been addressed in an existing GitHub issue.
Steps to reproduce
- Open Demo.xcodeproj
- Open CodeSyntaxHighlightView.swift
- Modity the content variable with long code snippet (more 75 lines and 3200 symbols). Example:
```
#include "EUC.h"
static const char* LOG_TAG = "ESP32-EUC";
static InmotionV2Unpacker* unpacker = new InmotionV2Unpacker();
static void eucNotifyReceived(NimBLERemoteCharacteristic* pChar, uint8_t* data, size_t length, bool isNotify) {
EUC.onEucNotifyReceived(pChar, data, length, isNotify);
};
class EucConnectCallbacks : public NimBLEClientCallbacks {
void onConnect(NimBLEClient* pClient) { EUC.onEucConnected(pClient); }
void onDisconnect(NimBLEClient* pClient) { EUC.onEucDisconnected(pClient); }
};
class AppConnectCallbacks : public NimBLEServerCallbacks {
void onConnect(NimBLEServer* pServer, ble_gap_conn_desc* desc) { EUC.onAppConnected(pServer, desc); }
void onDisconnect(NimBLEServer* pServer) { EUC.onAppDisconnected(pServer); }
};
class AppCallbacks : public NimBLECharacteristicCallbacks {
void onWrite(NimBLECharacteristic* pChar) { EUC.onAppWrite(pChar); }
void onSubscribe(NimBLECharacteristic* pChar, ble_gap_conn_desc* desc, uint16_t subValue) {
(subValue > 0) ? EUC.onAppSubscribe(pChar, desc) : EUC.onAppUnsubscribe(pChar, desc);
}
};
void eucClass::setup() {
NimBLEDevice::init("V11-ESP32EUC");
}
void eucClass::createAppBleServer() {
if (EUC.appServer != nullptr)
return;
ESP_LOGD(LOG_TAG, "Creating BLE server...");
EUC.appServer = NimBLEDevice::createServer();
EUC.appServer->setCallbacks(new AppConnectCallbacks());
NimBLEService* appService = EUC.appServer->createService(uartServiceUUID);
NimBLEService* appFfe5 = EUC.appServer->createService(ffe5ServiceUUID);
NimBLEService* appFfe0 = EUC.appServer->createService(ffe0ServiceCharUUID);
NimBLECharacteristic* appTxCharacteristic = appService->createCharacteristic(txCharUUID, NIMBLE_PROPERTY::WRITE | NIMBLE_PROPERTY::WRITE_NR);
NimBLECharacteristic* appRxCharacteristic = appService->createCharacteristic(rxCharUUID, NIMBLE_PROPERTY::NOTIFY);
NimBLECharacteristic* appFfe9Characteristic = appFfe5->createCharacteristic(ffe9CharUUID, NIMBLE_PROPERTY::WRITE | NIMBLE_PROPERTY::WRITE_NR);
NimBLECharacteristic* appFfe4Characteristic = appFfe0->createCharacteristic(ffe4CharUUID, NIMBLE_PROPERTY::NOTIFY);
appService->start();
NimBLEAdvertising* appAdvertising = NimBLEDevice::getAdvertising();
appAdvertising->addServiceUUID(uartServiceUUID);
appTxCharacteristic->setCallbacks(new AppCallbacks());
appRxCharacteristic->setCallbacks(new AppCallbacks());
appFfe9Characteristic->setCallbacks(new AppCallbacks());
appFfe4Characteristic->setCallbacks(new AppCallbacks());
NimBLEDevice::startAdvertising();
NimBLEDevice::stopAdvertising();
}
void eucClass::startBleScan() {
if (EUC.advertisedDevice != nullptr)
return;
if (EUC.failedScanCount > 5)
return;
if (EUC.latestScan > 0 && millis() - EUC.latestScan < 10000)
return;
LED.scanStart();
ESP_LOGD(LOG_TAG, "Scanning for BLE device...");
NimBLEScan* pScan = NimBLEDevice::getScan();
pScan->setAdvertisedDeviceCallbacks(new EUCFoundDeviceCallbacks(), false);
pScan->start(3);
LED.scanStop();
ESP_LOGD(LOG_TAG, "Stop scanning for BLE device...");
EUC.latestScan = millis();
EUC.failedScanCount++;
}
```
- Run the project on any iPhone
- Open 'Syntax Highlighting' section in the app
Expected behavior
Opened the 'Syntax Highlighting' with highlighting without crash
Screenshots


Version information
- MarkdownUI: 2.4.1
- OS: iOS 18.3.1
- Xcode: 16.2
Additional context
- There is no crash on the macOS 15.2 (Macbook Pro M2 Pro)
- There is no crash without markdownCodeSyntaxHighlighter modifier
ondrejkorol
Metadata
Metadata
Assignees
Labels
No labels