• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

cleaning up processes when ExtensionUnloaded

Contributor ,
Jun 13, 2021 Jun 13, 2021

Copy link to clipboard

Copied

Dear ppro fellows,

I'm trying to kill processes spawned by my CEP panel after the panel is closed.

As specialists from this forum explained, to register the ExtensionUnloaded event from my CEP panel I need to have the invisibale custom CEP panel which starts when ppro starts. 

Therefore:

Frist: in manifest.xml I added the second invisible extension and added to it:

<StartOn>
    <Event>applicationActivate</Event>
    <Event>com.adobe.csxs.events.ApplicationActivate</Event>
</StartOn>

And indeed, as far as I understand, this invisible panel starts when ppro starts.

Second:

in my index.js of  the invisible panel I'm listening for an 

com.adobe.csxs.events.ExtensionUnloaded

event:

csInterface.addEventListener("com.adobe.csxs.events.ExtensionUnloaded", function(){
alert("Closed app");
});

 But then, strange thing happens. When I start my ppro 

the "com.adobe.csxs.events.ExtensionUnloaded" is triggered somehow right on the start and I see this alert "Closed app".

Of course, when I close my visible CEP this alert is triggered again. But how can I get rid of this thing on the ppro start?

Is it because when ppro starts it unloads some panels and this alert is triggered by another unrelated to my extension event?

If so, is it possible to catch the unload event from my visible panel (with my ID) only?

Yaroslav.

 

 

 

 

 

TOPICS
SDK , User interface or workspaces

Views

574

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 2 Correct answers

Contributor , Jun 14, 2021 Jun 14, 2021

Check event data for information about what extension was unloaded.

csInterface.addEventListener('com.adobe.csxs.events.ExtensionUnloaded', function(evt) {
  console.log(evt.data);
});

 

Votes

Translate

Translate
Contributor , Jun 14, 2021 Jun 14, 2021

I don't know if I do it proper way, but I just check it like this:

csInterface.addEventListener('com.adobe.csxs.events.ExtensionUnloaded', function(evt) {
  var extID = "your.extension.id";
  if (evt.data.indexOf(extID) > -1) {
    // your code
  }
});

Votes

Translate

Translate
Contributor ,
Jun 14, 2021 Jun 14, 2021

Copy link to clipboard

Copied

Check event data for information about what extension was unloaded.

csInterface.addEventListener('com.adobe.csxs.events.ExtensionUnloaded', function(evt) {
  console.log(evt.data);
});

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Jun 14, 2021 Jun 14, 2021

Copy link to clipboard

Copied

Thanks, Ivan!

That did help and illuminated things.

As I found out evt.data return literally this:

<ExtensionUnloadedEvent>
	<Id>com.adobe.ccx.start</Id>
	<ClosingType>4</ClosingType>
</ExtensionUnloadedEvent>

This Id is not, of course,  the Id of my application.

So in the function of event Listener I need to add additional condition: check extention Id.

My last question is how do you get Id from event.data. I tried: 

evt.data.attrubutes'Id');
evt.data.attr('Id');
evt.data.getAttribute('Id');

Nothing worked.

Yaroslav.

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Jun 14, 2021 Jun 14, 2021

Copy link to clipboard

Copied

I don't know if I do it proper way, but I just check it like this:

csInterface.addEventListener('com.adobe.csxs.events.ExtensionUnloaded', function(evt) {
  var extID = "your.extension.id";
  if (evt.data.indexOf(extID) > -1) {
    // your code
  }
});

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Sep 23, 2021 Sep 23, 2021

Copy link to clipboard

Copied

LATEST

I have to implement the same behavior but this event fires only in

Premier pro 2019.  But in the Premier pro 2020 and Premier pro 2021 it doesn't. Doest it work for you in them? I also tried the next trick, 

const process = cep_node.process;

export function onExit(callback) {
  process.on('exit', callback);
  process.on('SIGINT', callback);
};

onExit(function() {
   cep.fs.writeFile("/tmp/123.txt", "exited");
});

 But it also doesn't work in some cases. For example, if there are no open projects this approach doesn't work too.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines