After researching my code, it seems that some FONT OBJECT DISPLAY code for displaying quickly on iOS will not work in the Mac Simulator. Has anyone else seen this problem?
I’m concerned that the same will be true on the fastest Android and iOS devices - I’ll have to find out.
But in Simulator, this is a real problem that needs to be looked into.
Can you find the Corona simulator icon in the /Applications/Corona-nnnn folder, right-click ( or ctrl-click ) and choose “Get Info” and let me know if “Open in Low Resolution” is checked or not?
I have narrowed the issue down to display.capture - it’s likely not related to the font, except that my code was merging numerous images into a single group.
I’m creating a very small sample to show you the problem.
Please take just a few moments to recreate this bug and see how it is fixed - but then, dive deeper to see that I’ve only uncovered one symptom of a larger issue.
A) The problem is definately display.capture. Do you have a way to thoroughly test it in Simulator to find the problem?
B) This next question is only related to the CoronaSplashControl plugin, which is NOT the problem, but disabling it does solve the problem in ONE case - in the example below. Read my full explaination in section 4. Is the CoronaSplashControl plugin deprecated? if not, I’ve only purchased it one time when it went into effect - but it says $99/year. And when I log in, it says it is Activated. It is really $99/one-time?
Here are the 36 lines of code for main.lua to recreate the problem - this should display 3 lines of text, but it only displays 2 lines. If you comment out the plugin, all 3 lines appear properly. What is strange, however, is that now when I go to my larger application and take out the plugin or splash code, the problem still exists. This tells me that in this sample, the display.capture is still defective on MacOS and even though it can be solved by taking out the plugin in this example, the underlying problem remains.
–=======================================================================================
local snapIdx=0
local img
local function toSnapObj(dispObj, x, y)
if system.getInfo(“platform”)==“Android” then
snapIdx=snapIdx + 1
if snapIdx == 500 then snapIdx=1 end
local fileName=“tmp”…snapIdx…".png"
display.save(dispObj,
{
filename=fileName,
baseDir=system.CachesDirectory,
captureOffscreenArea=false,
backgroundColor={0,0,0,0}
})
img=display.newImage(fileName, system.CachesDirectory)
else – iOS and Simulator on Mac OS
img=display.capture(dispObj, {captureOffscreenArea=true})
end
img.x=x
img.y=y
display.remove(dispObj);dispObj=nil
return img
end
–=======================================================================================
W=display.viewableContentWidth; H=display.viewableContentHeight
local font=native.systemFont
local fontSize=H*0.08
local x=W*0.50; local y=H*0.25
local text_D=display.newText(“This is a test”,x,y,font,fontSize)
text_D=toSnapObj(text_D,text_D.x,text_D.y)
local text2_D=display.newText(“This is another test”,x,text_D.y+fontSize,font,fontSize)
text2_D=toSnapObj(text2_D,text2_D.x,text2_D.y)
local text3_D=display.newText(“This is YET another test”,x,text2_D.y+fontSize,font,fontSize)
text3_D=toSnapObj(text3_D,text3_D.x,text3_D.y)
– if you are wondering why I am doing this with these text objects, it’s because my code actually does this with a group of numerous text shadows to create a single shadow object. In this sample, no shadow is necessary to see the missing object.
– I am also converting hundreds of tiles into a single game board object using this technique, which significantly improves performance for my game board which is dynamically generated.
This would be much more helpful if you put it together and put it in a .zip file and provide a download link to the file. I really can’t take this to Engineering like this.
The splash screen control is $99/year and has to be renewed each year. It is not deprecated. Also keep in mind, deprecated means “it works for now, but may not work in the future”, but even with that definition, it should be working and not deprecated. The splash screen control plugin should have no effect on the simulator. It’s interesting that it has any effect at all.
Why don’t you have a config.lua? Does having a config.lua change the behavior?
If you want, you can use the HelloWorld config.lua - no change in behavior.
I really do appreciate you getting the team on this right away. I cannot reliably test/check my game code in many places where display.capture is used on simulator - I use it in more than half a dozen places.
when do I have to renew the $99/yr? Will I get a notice before it is shut off? I thought it has already been a year.
As for the splash screen, you would probably get a message during building that you’re not subscribed to the plugin. I can’t look that information up, you will need to email support AT coronalabs.com and ask them to look it up for you.
@Rob, I’m running:
macOS High Sierra, Version 10.13.4
MacBook Pro (13-inch, 2017, Four Thunderbolt 3 Ports)
Processor 3.3 GHz Intel Core i5
Memory 16GB 2133 MHz LPDDR3
Graphics Intel Iris Plus Graphics 650 1536 MB
Model Name: MacBook Pro
Model Identifier: MacBookPro14,2
Processor Name: Intel Core i5
Processor Speed: 3.3 GHz
Number of Processors: 1
Total Number of Cores: 2
L2 Cache (per Core): 256 KB
L3 Cache: 4 MB
Memory: 16 GB
Boot ROM Version: MBP142.0173.B00
SMC Version (system): 2.44f1
I’m looking at your code and was wondering. Can you try this for me:
local function toSnapObj(dispObj, x, y) if system.getInfo("platform")=="Android" then snapIdx=snapIdx + 1 if snapIdx == 500 then snapIdx=1 end local fileName="tmp"..snapIdx..".png" display.save(dispObj, { filename=fileName, baseDir=system.CachesDirectory, captureOffscreenArea=false, backgroundColor={0,0,0,0} }) img=display.newImage(fileName, system.CachesDirectory) else -- iOS and Simulator on Mac OS img=display.capture(dispObj, {captureOffscreenArea=true}) end img.x=x img.y=y -- CHANGE BEGINS timer.performWithDelay(60, function() display.remove(dispObj) end ) -- CHANGE ENDS return img end
I have found that deleting the the same frame as a display.save() or capture() sometimes causes issues. Waiting one or two frames usually does the trick.
Also, FYI, this is unnecessary:
dispObj=nil
That variable is temporary so you don’t need to clear it. It will go away and clear its reference to the object as soon as the function ends.
You may be wondering, yeah, “but why does the behavior change when I comment out plugin”. Probably a timing change is all. i.e. Just random luck that helped you encounter the issue.
I seriously doubt the plugin itself has any effect on the rendering of text, especially since it doesn’t run or do anything in the simulator. Its possible, but … well let’s see what the delay I suggested does for you.
@roaminggamer, thanks for your time on this. I had already ruled out the delay, but I tested your recommended change anyway. No luck. I also changed it to a higher value, too - nothing different.
@Rob, I commented out the display.remove line just to see what would happen - please notice that you can see the corruption of the original text of the first line.
@Corona, what’s up with this issue? Can’t you duplicate it? Although my example is simple, this happens all over my app and it looks as if it is poking into random memory - as I said, even once caused a hard crash on my Mac. Something in how the graphics are being displayed - its very serious. Sometimes, Corona just sits for 5-10 seconds with the wheel spinning in simulator, too. Please help.