Git Product home page Git Product logo

Comments (4)

lovyan03 avatar lovyan03 commented on August 18, 2024

@tobozo
Thanks for the report.

I was not able to reproduce the problem,
but I updated the develop branch with a change to discard the sprites once when setPsram is changed.

Are there any other prerequisites to reproduce the problem?
If you change the board type, will the problem go away?

from lovyangfx.

tobozo avatar tobozo commented on August 18, 2024

[edit] simplified POC code
[edit2] : pinpointed the issue

static LGFX_Sprite *sprite = new LGFX_Sprite( &tft ); // no crash when using this
static TFT_eSprite *sprite = new TFT_eSprite( &tft ); // will crash on createSprite()

The problem seems to be isolated to LoLin D32 Pro + TFT-2.4. No other component is connected.

I can't reproduce this issue on M5Stack or Odroid-Go.

Updating the develop branch did not solve it,

Are there any other prerequisites to reproduce the problem?

I have reduced the crash code to this:

#include <ESP32-Chimera-Core.h>
#define tft M5.Lcd

class BLAH {
  public:
    BLAH(){
      if( !psramInit() ) {
        log_e("Failed to init psram, crash will probably occur");
      } else {
        log_d("Psram successfully detected");
      }
    };
    ~BLAH() { };
};

static BLAH bleb;

// static LGFX_Sprite *keyNoteSprite = new LGFX_Sprite( &tft ); // no crash when using this
static TFT_eSprite *keyNoteSprite = new TFT_eSprite( &tft );

void setup()
{
  M5.begin();
  void* sptr = keyNoteSprite->createSprite( tft.width(), tft.height() );
  if( !sptr )  {
    log_e("Can't create sprite, aborting");
    while(1) vTaskDelay(1);
  }
}


void loop()
{

}

... is premature psramInit() causing this ?

from lovyangfx.

lovyan03 avatar lovyan03 commented on August 18, 2024

The psramInit function seems to be called at startup in the initArduino function.
I don't see any need to call it explicitly from user code.
If you call it in the constructor of a static object, I think it is called before initArduino.

Therefore, this is sufficient to reproduce the problem.

#include <Arduino.h>
#include <esp_log.h>

class BLAH {
  public:
    BLAH(){
      if( !psramInit() ) {
        log_e("Failed to init psram, crash will probably occur");
      } else {
        log_d("Psram successfully detected");
      }
    };
    ~BLAH() { };
};

static BLAH bleb;

void setup()
{
  void* sptr = heap_caps_malloc(320*240*2, MALLOC_CAP_SPIRAM);
  if( !sptr )  {
    log_e("Can't heap_caps_malloc, aborting");
  }
  else
  {
    log_e("success !");
  }
}


void loop()
{
  vTaskDelay(1);
}

from lovyangfx.

tobozo avatar tobozo commented on August 18, 2024

ok I understand this is a bad practice causing that, I'm not sure why it only crashes with LoLin D32 Pro + TFT-2.4 though.

closing this issue as not a LGFX problem

from lovyangfx.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.