Wednesday, 1 August 2018

Expected dynamic type `double', but had type `null' (Constructing arguments for Timing.createTimer at index 1)

I have been getting this error Expected dynamic type `double', but had type `null' (Constructing arguments for Timing.createTimer at index 1) when I run react-native android. When I try locating Timing.createTimer I found it that it's being used in 3 places inside node_modules/react-native/Libraries/Core/Timers/JSTimers.js:

1

setTimeout: function(
func: Function,
duration: number,
...args?: any
): number {
    if (__DEV__ && IS_ANDROID && duration > MAX_TIMER_DURATION_MS) {
      console.warn(
        ANDROID_LONG_TIMER_MESSAGE +
          '\n' +
          '(Saw setTimeout with duration ' +
          duration +
          'ms)',
      );
    }
    const id = _allocateCallback(
      () => func.apply(undefined, args),
      'setTimeout',
    );
    Timing.createTimer(id, duration || 0, Date.now(), /* recurring */ false);
    return id;
  }

2

setInterval: function(
func: Function,
duration: number,
...args?: any


): number {
    if (__DEV__ && IS_ANDROID && duration > MAX_TIMER_DURATION_MS) {
      console.warn(
        ANDROID_LONG_TIMER_MESSAGE +
          '\n' +
          '(Saw setInterval with duration ' +
          duration +
          'ms)',
      );
    }
    const id = _allocateCallback(
      () => func.apply(undefined, args),
      'setInterval',
    );
    Timing.createTimer(id, duration || 0, Date.now(), /* recurring */ true);
    return id;
  }

3

  requestAnimationFrame: function(func: Function) {
    const id = _allocateCallback(func, 'requestAnimationFrame');
    Timing.createTimer(id, 1, Date.now(), /* recurring */ false);
    return id;
  }

invoke method is define inside JavaMethodWrapper.java 368 line

   @Override
   public void invoke(JSInstance jsInstance, ReadableNativeArray parameters) {
    ....
        try {
            for (; i < mArgumentExtractors.length; i++) {
              mArguments[i] = mArgumentExtractors[i].extractArgument(
                jsInstance, parameters, jsArgumentsConsumed);
              jsArgumentsConsumed += mArgumentExtractors[i].getJSArgumentsNeeded();
            }
          } catch (UnexpectedNativeTypeException e) {
            throw new NativeArgumentsParseException(
              e.getMessage() + " (constructing arguments for " + traceName + " at argument index " +
                getAffectedRange(jsArgumentsConsumed, mArgumentExtractors[i].getJSArgumentsNeeded()) +
                ")",
              e);
          }
....
}

And it's being called from JavaModuleWrapper.java 162

    @DoNotStrip
  public void invoke(int methodId, ReadableNativeArray parameters) {
    if (mMethods == null || methodId >= mMethods.size()) {
      return;
    }

    mMethods.get(methodId).invoke(mJSInstance, parameters);
  }

Things I tried:

  1. Tried guarding against a null id before Timing.createTimer is being called by doing if (id == null || id = '') { return null }
  2. Tried printing the id that was being set before Timing.createTimer, but it caused the app to stop responding since it's triggering almost every second

Any help will be much appreciated. Thanks in advance

PS: I read about every post there is related to this problem couldn't find a solution that applies



from Expected dynamic type `double', but had type `null' (Constructing arguments for Timing.createTimer at index 1)

No comments:

Post a Comment