adobe / XMP-Toolkit-SDK

The XMP Toolkit allows you to integrate XMP functionality into your product or solution
BSD 3-Clause "New" or "Revised" License
205 stars 83 forks source link

Photoshop on MAC: "Export->Save for Web(Legacy)" crashes when a Plugin with XMP-Toolkit is installed #84

Open thstapel opened 11 months ago

thstapel commented 11 months ago

I have a plugin which is using the XMP-Toolkit-SDK. I found out that if this plugin is installed, Photoshop crashes when trying to save an image via "File -> Export -> Save for Web(Legacy). All other Saving/Exporting functions in Photoshop seems fine so far.

Attached is the crash-report given by Apple CrashReport.txt

As it can be seen here, the XMP-Toolkit is directly called from "Save for Web", so I have no chance to put something into my code to avoid writing Metadata in that case.

0   libsystem_pthread.dylib             0x7ff80aa6e4ac pthread_mutex_lock + 4
1   libGMGSharedPsPlugin.dylib             0x14d3b4782 XMP_HomeGrownLock::AcquireForWrite() + 18
2   libGMGSharedPsPlugin.dylib             0x14d3b5286 XMP_NamespaceTable::Define(char const*, char const*, char const**, unsigned int*) + 70
3   libGMGSharedPsPlugin.dylib             0x14d37022f XMPMeta::RegisterNamespace(char const*, char const*, char const**, unsigned int*) + 47
4   libGMGSharedPsPlugin.dylib             0x14d416794 0x14d2a3000 + 1521556
5   libGMGSharedPsPlugin.dylib             0x14d414abb 0x14d2a3000 + 1514171
6   libGMGSharedPsPlugin.dylib             0x14d412ed3 0x14d2a3000 + 1507027
7   libGMGSharedPsPlugin.dylib             0x14d4105d7 0x14d2a3000 + 1496535
8   libGMGSharedPsPlugin.dylib             0x14d40f01a 0x14d2a3000 + 1490970
9   libGMGSharedPsPlugin.dylib             0x14d40b911 0x14d2a3000 + 1476881
10  libGMGSharedPsPlugin.dylib             0x14d40b17b XML_ParseBuffer + 171
11  libGMGSharedPsPlugin.dylib             0x14d3a7171 ExpatAdapter::ParseBuffer(void const*, unsigned long, bool) + 65
12  libGMGSharedPsPlugin.dylib             0x14d36abdd 0x14d2a3000 + 818141
13  libGMGSharedPsPlugin.dylib             0x14d36a853 XMPMeta::ProcessXMLBuffer(char const*, unsigned int, bool) + 867
14  libGMGSharedPsPlugin.dylib             0x14d36ae98 XMPMeta::ParseFromBuffer(char const*, unsigned int, unsigned int) + 136
15  libGMGSharedPsPlugin.dylib             0x14d35f461 WXMPMeta_ParseFromBuffer_1 + 81
16  libGMGSharedPsPlugin.dylib             0x14d2e85f1 TXMPMeta<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>::TXMPMeta(char const*, unsigned int) + 113
17  Save for Web                           0x1f9d39dd3 S4WTargetGenerationContext::MakeMetadataImageResources(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&, MetadataOutputSettings const&) + 159

I find it somehow strange that crash happens even if I do not call any part of the XMP-Toolkit actively, it needs to be just there in the code.

Example: I have the following call: .h-File:

#if defined(Q_OS_MAC)
#ifndef MAC_ENV
#define MAC_ENV
#endif
#else
#ifndef WIN_ENV
#define WIN_ENV
#endif
#endif

#define TXMP_STRING_TYPE std::string
#include <XMP.hpp>
class GMGSHAREDPSPLUGINSHARED_EXPORT XmpManager
{
public:
    XmpManager();
    ~XmpManager();
private:
    std::unique_ptr<SXMPMeta> _xmpData;
};

.cpp-File:

XmpManager::XmpManager()
{
     _xmpData = std::unique_ptr<SXMPMeta> (new SXMPMeta());
}

XmpManager::~XmpManager()
{
      _xmpData.reset();
}

This code will lead to the crash, even if I do not call the constructor at all. When I comment out _xmpData = std::unique_ptr<SXMPMeta> (new SXMPMeta());, it is fine. This seems to me like a very strange behaviour.

Platform and Version

MAC-OS: Tested with 14.2 and 13.6 on both Intel and Arm, all are reproducable Photoshop-Version: Tested with 22, 23 and 24, all reproducable Toolkit-Version: February 2022 has the problem, older Version of my Plugin which use a version from 2014 does not crash

Windows: Working fine Illustrator on Mac: Working fine