Giter VIP home page Giter VIP logo

Comments (20)

danielesegato avatar danielesegato commented on May 22, 2024

I also can't import FBX with assimp on Android

I don't have the full stack trace but I have this error:
09-13 09:24:26.365 6053-6053/com.qualcomm.QCARSamples.FrameMarkers A/libc﹕ Fatal signal 7 (SIGBUS) at 0x746421ea (code=1), thread 6053 (es.FrameMarkers)

I think it may be related

from assimp.

sherief avatar sherief commented on May 22, 2024

Can we get the FBX file(s) you used so we can reproduce?

from assimp.

jdduke avatar jdduke commented on May 22, 2024

Any of the binary FBX files in our test data folder should trigger it.

from assimp.

antoniovazquezblanco avatar antoniovazquezblanco commented on May 22, 2024

I'm interested in assimp releasing a new version of their software so I will try to push this oldest issues a bit.

Is there any news on this issue since the last comment?

Thanks in advance.

from assimp.

nevinrebel avatar nevinrebel commented on May 22, 2024

I've also ran into this issue as well. Any update?

I have assimp loading other formats such as .obj but it's failing on fbx.

Thanks

from assimp.

mfvanaclocha avatar mfvanaclocha commented on May 22, 2024

same here with:

const struct aiScene* assimpScene = importer.ReadFileFromMemory((const void *) buffer,
lenght,
aiProcess_Triangulate | aiProcess_GenSmoothNormals,
"fbx");

from assimp.

mfvanaclocha avatar mfvanaclocha commented on May 22, 2024

solved

in FBXParser.cpp -> ParseTokenAsFloat

in android there is a sigbus because bad memory aligment, i've solved it with memcpy //commented parts are the previous ones

if(t.IsBinary())
{
const char* data = t.begin();
if (data[0] != 'F' && data[0] != 'D') {
err_out = "failed to parse F(loat) or D(ouble), unexpected data type (binary)";
return 0.0f;
}

    if (data[0] == 'F') {
        ai_assert(t.end() - data == 5);
        // no byte swapping needed for ieee floats
        float returnFloat;
        memcpy(&returnFloat, data+1, sizeof(float));
        return returnFloat;//*reinterpret_cast<const float*>(data+1);
    }
    else {
        ai_assert(t.end() - data == 9);
        // no byte swapping needed for ieee floats
        double returnFloat;
        memcpy(&returnFloat, data+1, sizeof(double));
        return (float) returnFloat;//static_cast<float>(*reinterpret_cast<const double*>(data+1));
    }
}

from assimp.

acgessler avatar acgessler commented on May 22, 2024

Awesome finding.

I strongly suspect that other loaders are suspected of similar code as well ...

from assimp.

mfvanaclocha avatar mfvanaclocha commented on May 22, 2024

currently i've integrated assimp to my c++ opengl engine for android and ios, if i found any other issue i will post it

my patch is a little uggly but it was a hotfix, how you will integrate it in a cleaner way?

from assimp.

acgessler avatar acgessler commented on May 22, 2024

I think we'll go with memcpy.

reinterpret_cast breaks strict aliasing rules. The union trick is allowed by many compilers, but strictly speaking it is a violation of a rule that writing to an union with type A and directly thereafter reading with type B is undefined behaviour as well.

from assimp.

acgessler avatar acgessler commented on May 22, 2024

Thanks! Very glad to solve this. Re-open if the issue persists (I don't have the means of checking on Android right now ... )

from assimp.

jdduke avatar jdduke commented on May 22, 2024

I've noticed a number of other places in FBXParser.cpp where we reinterpret_cast doubles, uint64s, etc... Are they not also candidates for the memcpy workaround?

from assimp.

acgessler avatar acgessler commented on May 22, 2024

Frankly, yes, almost every reinterpret_cast in the entire library should be a candidate. I just saw there is plenty of them.

from assimp.

sdsunqian avatar sdsunqian commented on May 22, 2024

Any update? Still got crash if loading fbx files on Android.

from assimp.

turol avatar turol commented on May 22, 2024

You can use Clang's undefined sanitizer to debug this on desktop. It will shout at you whenever you do unaligned loads. GCC 5 should also have this feature. You might have to use Linux though, not sure what Clang windows status is.

from assimp.

vinjn avatar vinjn commented on May 22, 2024

I have also experienced this issue - binary fbx file can't be loaded on Android.
I have narrowed down the problem to buggy behavior of AndroidJNIIOSystem.
https://github.com/assimp/assimp/blob/master/port/AndroidJNI/AndroidJNIIOSystem.cpp

By using irrlicht and leveraging its filesystem interface, I have solved the problem.
https://github.com/zaki/irrlicht/blob/ogl-es/source/Irrlicht/Android/CAndroidAssetReader.cpp

from assimp.

ruzannakamalyan avatar ruzannakamalyan commented on May 22, 2024

Hi, I'm getting a similar error, however the fixes mentioned here are applied.
I'm using the compiled .so of the latest version of assimp.

I/DEBUG(191): Revision: '11'
I/DEBUG(191): ABI: 'arm'
I/DEBUG(191): signal 7 (SIGBUS), code 1 (BUS_ADRALN), fault addr 0x9c79f32a
I/DEBUG(191): r0 9c79f332 r1 a37ad0b4 r2 9c79f332 r3 9c79f32a
I/DEBUG(191): r4 b9a20c10 r5 9caef1c0 r6 9c4b5008 r7 00000000
I/DEBUG(191): r8 b99a7c50 r9 a37ad838 sl b98e5eb0 fp a37ad094
I/DEBUG(191): ip 00000000 sp a37ad060 lr 9d0642e0 pc 9d064328 cpsr 600f0010
I/DEBUG(191): backtrace:
I/DEBUG(191): #00 pc 008c4328 /data/app/lib/arm/libAssimp32.so (Assimp::FBX::ParseTokenAsID(Assimp::FBX::Token const&, char const_&)+260)
I/DEBUG(191): #1 pc 008fb350 /data/app/lib/arm/libAssimp32.so (Assimp::FBX::Document::ReadObjects()+988)
I/DEBUG(191): #2 pc 008f9874 /data/app/lib/arm/libAssimp32.so (Assimp::FBX::Document::Document(Assimp::FBX::Parser const&, Assimp::FBX::ImportSettings const&)+276)
I/DEBUG(191): #3 pc 008c23d8 /data/app/lib/arm/libAssimp32.so (Assimp::FBXImporter::InternReadFile(std::string const&, aiScene_, Assimp::IOSystem_)+860)
I/DEBUG(191): #4 pc 0033d5fc /data/app/lib/arm/libAssimp32.so (Assimp::BaseImporter::ReadFile(Assimp::Importer const_, std::string const&, Assimp::IOSystem_)+244)
I/DEBUG(191): #5 pc 00353a9c /data/app/lib/arm/libAssimp32.so (Assimp::Importer::ReadFile(char const_, unsigned int)+1920)
I/DEBUG(191): #6 pc 0032ad98 /data/app/lib/arm/libAssimp32.so (aiImportFileExWithProperties+376)

Any suggestions? Thanks in advance.

from assimp.

kimkulling avatar kimkulling commented on May 22, 2024

I guess these errors are caused by the dynamic cast stuff done in the code. We haven't fixed all places until now.

from assimp.

kimkulling avatar kimkulling commented on May 22, 2024

See #1686

from assimp.

kimkulling avatar kimkulling commented on May 22, 2024

Closed by #1686

from assimp.

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.