Skip to content

fix: Ensure Isolate is alive before using it (#63) #69

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 17, 2020

Conversation

darind
Copy link
Collaborator

@darind darind commented Oct 15, 2020

Related to #63.

Steps to reproduce:

var worker = new Worker("./tests/shared/Workers/EvalWorker.js");

worker.onmessage = (msg) => {
    worker.terminate();
    NSNotificationCenter.defaultCenter.postNotificationNameObject("MyNotification", null);
};

const workerScript = `
  var NotificationObserver = /** @class */ (function (_super) {
    __extends(NotificationObserver, _super);
    function NotificationObserver() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    NotificationObserver.initWithCallback = function (onReceiveCallback) {
        var observer = _super.new.call(this);
        observer._onReceiveCallback = onReceiveCallback;
        return observer;
    };
    NotificationObserver.prototype.onReceive = function (notification) {
        this._onReceiveCallback(notification);
    };
    NotificationObserver.ObjCExposedMethods = {
        onReceive: { returns: interop.types.void, params: [NSNotification] },
    };
    return NotificationObserver;
  }(NSObject));

  const observer = NotificationObserver.initWithCallback(notification => {
  });

  NSNotificationCenter.defaultCenter.addObserverSelectorNameObject(observer, "onReceive", "MyNotification", null);

  postMessage(self === global);`;

worker.postMessage({ eval: workerScript });

@cla-bot cla-bot bot added the cla: yes label Oct 15, 2020
@darind darind self-assigned this Oct 15, 2020
@darind darind force-pushed the darind/isolate-aliveness-check branch from 0076296 to eebf95f Compare October 15, 2020 10:09
@NathanaelA

This comment was marked as abuse.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

iOS app crash after permission request when I use a worker
2 participants