Attempt to invoke virtual method 'void android.graphics.Point.setAntiAlias(boolean)' on a null object reference - codenameone

Within a Codename1 app, I'm getting a CrashReport: java.lang.NullPointException: Attempt to invoke virtual method 'void android.graphics.Point.setAntiAlias(boolean)' on a null object reference. This seems to occur after I invoke a "show()" on the main form of my application.
Note that the code runs fine in the simulator, but consistently gets this error prior to doing the "show()" on Android.
Interestingly, if I put a Dialog like this:
Dialog.show("Wait a sec", "Showing interrupt point", "OK", null);
before the .show(), and then click "OK", then everything runs well with no exceptions at all.
But a sleep(5000) instead of the Dialog does not help - still get the exception. So it at least seems like its not a race condition.
I have try-catches wrapped around all of the potentially offending code, and have NOT been able to isolate this. It always gets caught by the CrashReport, and only when running on the Android device.
Any ideas?

The symptoms to this one are pretty strange (i.e. workaround with a Dialog), and it would be interesting to have an explanation. However, since deprecated cn1 (Map) code has seemingly been implicated, I'm going to let this one go and replace this code with the latest Google native maps code. If it recurs, I will post another question then.

Related

React seems to be mangling variable names and then complaining they don't exist

Over the weekend, this bug (see attached image) appears to have crept in, I'm thinkning it was a dependency update, since the variable it's complaining about "_onAssign" does not appear once in the entire code base and the actual variable "onAssign" is defined in every case I have tested.
Is this a known result from something could I have done? (I'm still quite new to javascript and front end development, so that is enitirely possible)
extra note, this is not new code, and was working up until Friday evening, now all our builds are failing with this exact error.
_onAssign is not used anywhere, in any of our files, so it is rightly undefined. I would like to call the function onAssign
You need to console log that function and comment the whole other code so you won't get any error then see what it logs in the console and from there you can find out what is causing the error .

Not able to set list2 in Adobe Launch in custom code

I am trying to set list2 in my analytics call through custom code but it is not getting set.
This issue comes with s.tl() only while with s.t() method, it is triggered correctly.
Below is the code :-
s.addEvent("event12", true);
s.linkTrackVars = "list2";
s.list2 = "Data"
s.tl(this, "d", "Download", s);
If I place logger just before beacon call, it shows the value. However, when I click the button and check for same, only "event12" get fired and not "list2".
Any help would be highly appreciated.
Just tested your code on lululemon:
Conclusion:
You're overwriting either the listvar or the linkTrackVars somewhere else. As #Crayton Mentioned above, doPlugins would be a good spot for it.
But it actually can be overwritten anywhere. In any rule that fires prior, or the s code, or any DE affected.
Paste your code into the console. Execute. Do you see the listvar populated? If yes, then your problem is in rules, so check them. You're not supposed to reassign linktrackvars. Always use the s.apl() plugin.
If no, however, then your problem is definitely in doPlugins. Sometimes I have it when I have silent catches in s code. Pageviews would have all vars populated, but links would have mixed results. Check your error reporting in the catches in doPlugins. I suggest having all code in doPlugins in a try catch.

Uipath try/catch problem - throwing system exception

Having some trouble with try/catch in UiPath:
Got two different projects with their own workflows, with try catch implementations exactly the same in both.
However, one of the try/catch is working absolutely fine, whereas the other one is giving troubles with the following error when I Throw an exception, and then the steps defined in the catch block doesn't even trap it and execute.
Thoughts/Suggestions will be much appreciated - Thanks!
RemoteException wrapping System.Exception: <My user defined message>
at System.Activities.Statements.Throw.Execute(CodeActivityContext context)
at System.Activities.CodeActivity.InternalExecute(ActivityInstance instance, ActivityExecutor executor, BookmarkManager bookmarkManager)
at System.Activities.ActivityInstance.Execute(ActivityExecutor executor, BookmarkManager bookmarkManager)
at System.Activities.Runtime.ActivityExecutor.ExecuteActivityWorkItem.ExecuteBody(ActivityExecutor executor, BookmarkManager bookmarkManager, Location resultLocation)
If you have been using the Try Catch with the general Exception, it should be working in the same way in any project.
I believe you was a bit confused by the running mode.
So I assume in one project you fired the project in the debug mode. This stops on the exception when it occurs. If happening you need to hit the continue button.
But if you run the project with the Run button, it will ignore the exception handling as breakpoint and will continue now without any break.
So make sure in a live test you always run it with the run button and not with the usual debug button.

opencti "setSoftphonePanelVisibility" has no effect if "isSoftphonePanelVisible" was invoked before

Background:
In Lightning mode, when the Lightning console App is displayed, and based on a specicific message received from my 3rd-party app, I invoke sforce.opencti.setSoftphonePanelVisibility(true), the softphone is first hidden (shortly), then shown again.
As I debugged my code, I could verify, that invoking
sforce.opencti.setSoftphonePanelVisibility(true) led to this behavior.
So, I decided to first invoke
sforce.opencti.isSoftphonePanelVisible(), then depending on the response in its callback, I decide to invoke
sforce.opencti.setSoftphonePanelVisibility(true) or not.
The problem is, when I do this, sforce.opencti.setSoftphonePanelVisibility(true) has then no effect, allthough the OpenCTI call is responded correctly (response.success=true and response.errors=undefined): The softphone is still minimized.
Thanks in advance.
just to share how I solved (workaround) this issue.
A good functional workaround I had implemented was to first of all invoke sforce.opencti.setSoftphonePanelVisibility({visible:true}); in your initialization phase of the softphone. I then check the content of the GUI to be displayed. If there are calls to be display, the softphone has to remain visible. Otherwise, it will be hidden using sforce.opencti.setSoftphonePanelVisibility({visible:false});.
All subsequent calls of sforce.opencti.isSoftphonePanelVisible(); followed by sforce.opencti.setSoftphonePanelVisibility({visible:true}); will be functional to 100%.
It seems that OpenCTI expects that sforce.opencti.setSoftphonePanelVisibility({visible:true}); is invoked first before sforce.opencti.isSoftphonePanelVisible();.

How do I find the context in which document.write operates. Can you solve the riddle

Basically i have these two lines of code written right after each other.:
console.log(typeof (noAdsCallback));
document.write('<sc' + 'ript type="text/javascript">console.log(typeof(noAdsCallback));</scr' + 'ipt>');
The first one logs function, the second logs undefined.
Of course it's a bit trickier than that. So here is the set-up in a nutshell:
I have a so called waterfall of ad-providers. That means, I try to load some Ads, by writing (using document.write) some special tags (given to me by my ad-provider).
If the provider doesn't find an ad for me, they send back a javascript-snippet which looks like this:
if (typeof(window.noAdsCallback) === "function") noAdsCallback();
This function essentially writes the tags of the next provider, which does the same as the first one until I reach the end of the list.
This system actually works fine, doing exactly what I want it to do. Both lines given in the beginning log function.
Except if I use Google as an ad-provider. There is one thing Google does differently, which seems to mess everything up.
In Google, I cannot define a fallback-JavaScript-snippet. All I can do is provide a fallback-url. So this fallback-url (since it's loaded inside an iframe inside an iframe inside...) sends a postMessage to the top, which then calls the same noAdsCallback() method. And this too, works just fine. The message is received and the right method executed. However, already the two lines already give different results, i.e. function and undefined respectively
The next provider then fails to find the noAdsCallback() Method, when it returns, because it uses document.write to try to execute it. Somehow, the context was lost.
First hint: It works fine (i.e. both lines log function) in Chrome, but it doesn't work in FF or IE.
Second hint: It works fine, as long as context never switches, but if communication runs at any point through messaging, it get's confused.
Third hint: Using the fantastic postscribe library as mentioned below, actually solves the problem, but introduces new ones somewhere else.
Fourth hint: Debugging the window.name, before using document.write, gives the correct name, so I'm not in a random iFrame.
Finishing thoughts. I know, i know: DON'T USE DOCUMENT WRITE!! I know that. But since Adproviders use it all the time, I am forced to use it to, otherwise I get this:
Failed to execute 'write' on 'Document': It isn't possible to write into a document from an asynchronously-loaded external script unless it is explicitly opened.
In Fact, right now I'm using postscribe (https://github.com/krux/postscribe) and it works like a charm, except for one lousey provider. And the workauround solution would be, to use document.write only for this lousy provider and postscribe for all the others. But i would really like to find out what the root of the problem is.
Any Ideas, much appreciated.
I think I understood it now. Long story short: DON'T USE DOCUMENT.WRITE :)
Try postscribe, if you have to.
So in hindsight it is quite obvious, because really, anywhere you read about document.write() it says, that write() clears the whole document. And I just didn't get it, because I never saw it happening and every ad is using it, like the whole time. Plus, it seemed to work fine on Chrome. So what's going on??
Well here is what happens. As long as the document is open, which basically means while it is being written, document.write() just appends to the stream, and doesn't clear the document. And as long as I used document.write(), to append foreign ad-scripts (which may and will contain document.write()), the page does not close, hence the document stays open.
This is the reason, why adding Google to my waterfall, posed a problem: Google puts everything in iframes. So the page containing the waterfall model just sees the iframe and says: "well as far as I'm concerned, I'm done" and closes the document, while in fact, Google is still at it.
Afterwards, Google didn't find an ad, sends a postMessage to the main page, causing the next provider to be used. Who then uses document.write() and clears everything.
Everything? Not everything. Remember, it still used to work when I used Chrome? The reason for that is, Chrome just clears the HTML but leaves the Javascript intact. So on Chrome, my Javascript-waterfall worked fine, because all the JS-objects where still in place. All other browsers cleared it.
So that's it. Probably noone's gonna read it, but if you do, USE POSTSCRIBE! Now that I finally really understood document.write() and document.open() and document.close() I'm a big fan.

Resources